I am creating 'my own launcher. In that case I want to putQuick search bar` in my home screen i.e. Google now launcher.
How can I do that. I have gone through multiple threads but not found any relevant answer.
I don't want to show the widget picker.I want asap user install this launcher search bar should be there.
Thanks in advance.
The search bar is not displayed because the launcher doesn't have permissions to show the widget.
As you probably already figured out, if a user explicitly adds the search bar widget to any screen, he will be prompted to give the permission, and the search bar on top also appears.
The problem is that
getOrCreateQsbBarmethod inLauncherclass (I assume you forked Launcher3) doesn't ask for permissions if it can't instantiate the widget, it instead silently fails. The problem is in this snippet inside ofgetOrCreateQsbBar:Instead of just resetting
widgetIdto-1you want to ask for permissions to install the widget and callgetOrCreateQsbBaragain. Here's an example code that asks for permission:Then overload
onActivityResultin theLauncherclass, something along the lines of: