テント内のURLへのAndroid応答し
-
22-08-2019 - |
質問
例えば、Androidマーケットは、でこれを行います。ユーザーが特定のURLになったときに
私は私の意図が起動されるようにしたいですhttp://market.android.com/
のURLを。そうユーチューブはありません。私は私があまりにもそれをやってみたい。解決
私はそれをやりました! <intent-filter>
に使用します。マニフェストファイルに次を置きます:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="www.youtube.com" android:scheme="http" />
</intent-filter>
これは完璧に動作します!
他のヒント
あなたはそれが(HTTP / HTTPS /電気ショック療法)別の例で動作するように得るためにあなたのインテントフィルタに異なる順列を追加する必要があります。
例えば、私は、ユーザーがリンクを開いたときに、ドライブのフォームをGoogleに開いてしまうのアプリのために次のことをしなければならなかった、www.docs.google.com/forms
そのパスプレフィックスは省略可能であることに注意してください。
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="docs.google.com"
android:pathPrefix="/forms"/>
<data
android:scheme="http"
android:host="www.docs.google.com"
android:pathPrefix="/forms" />
<data
android:scheme="https"
android:host="www.docs.google.com"
android:pathPrefix="/forms" />
<data
android:scheme="https"
android:host="docs.google.com"
android:pathPrefix="/forms" />
</intent-filter>
所属していません StackOverflow