I'm building a browser app in android and I want to allow the user to be able to open web searches from around the system in my browser.
For example web searches from selections:
And if possible searches from the home screen search widget.
Currently both open in the google app despite me registering an intent filter for WEB_SEARCH.
Here is my activity definition in AndroidManifest.xml
<activity
android:name=".Browser"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"
android:hardwareAccelerated="true"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:resizeableActivity="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.APP_BROWSER" />
</intent-filter>
<intent-filter>
<!-- Allows activity to be opened for links around the OS -->
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
<data android:scheme="https" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter>
<!-- *should* catches system google searches? wasn't able to trigger it -->
<action android:name="android.intent.action.WEB_SEARCH" />
<data android:scheme="http" />
<data android:scheme="https" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
I was expecting next time I hit web search for android to ask me which app I wished to use but so far nothing, it automatically goes to google app.
Found the solution
<intent-filter>
<action android:name="android.intent.action.WEB_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>