如何创建于Android清单浏览的意图是什么? [英] How do I create browsable intent in the android manifest?
问题描述
我有一个Android应用程序应该打开通过电子邮件发送链接。我只是想打开链接到一个特定的网站,虽然。我知道,打开YouTube链接可用于提供一个对话框,询问是否要在浏览器或在YouTube应用中打开它的用户,所以这就是我要的。在我的Android清单文件,我有以下意图过滤器:
I have an Android app that should open links sent via email. I only want to open links to a certain website, though. I know that opening youTube links provides the user with a dialog asking whether to open it in the browser or in the youTube app, so this is what I am going for. In my android manifest file, I have the following intent filters:
<activity android:name=".MyApp"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http"
android:host="mySite.com" />
</intent-filter>
</activity>
然后,要处理这个意图,我在的onCreate一行:
Then, to handle the intent, I have a line in onCreate:
if (getIntent().getCategories().contains("android.intent.category.BROWSABLE")){...}
问题是,如 HTTP链接://mySite.com#12345 不开这种方式。我在做什么错了?
The problem is that links such as http://mySite.com#12345 are not opening this way. What am I doing wrong?
推荐答案
答案是默认类别添加到第二个意图过滤器,就像@advantej建议。
The answer was to add the default category to the second intent filter, just as @advantej suggested.
这篇关于如何创建于Android清单浏览的意图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!