I am creating 'my own launcher. In that case I want to put
Quick 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
getOrCreateQsbBar
method inLauncher
class (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
widgetId
to-1
you want to ask for permissions to install the widget and callgetOrCreateQsbBar
again. Here's an example code that asks for permission:Then overload
onActivityResult
in theLauncher
class, something along the lines of: