Isa*_*ler 151 url android launch intentfilter android-intent
我希望在用户访问某个网址时启动我的意图:例如,Android市场通过http://market.android.com/网址进行此操作.youtube也是如此.我也希望我也这样做.
Isa*_*ler 190
我做的!用<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>
Run Code Online (Sandbox Code Playgroud)
这很完美!
您可能需要向intent过滤器添加不同的排列,以使其在不同的情况下工作(http/https/ect).
例如,我必须为应用程序执行以下操作,该应用程序会在用户打开指向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>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
110295 次 |
最近记录: |