私はAndroidでブラウザアプリを構築していますが、ユーザーがシステム全体からブラウザでWeb検索を開くことができるようにしたいと考えています。
たとえば、選択からのWeb検索:
そして、可能であれば、ホーム画面の検索ウィジェットから検索します。
現在、WEB_SEARCHのインテントフィルターを登録しているにもかかわらず、両方ともgoogleアプリで開いています。
これが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>
次回Androidのウェブ検索を押して、使用したいアプリを尋ねられると思っていましたが、今のところ何もありません。自動的にgoogleアプリに移動します。
解決策を見つけました
<intent-filter>
<action android:name="android.intent.action.WEB_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加