开发者

How do I create browsable intent in the android manifest?

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>

Then, to handle the intent, I have a line in onCreate:

if (getIntent().getCategories().contains("android.intent.category.BROWSABLE")){...}

The problem is that links such as http://mySite.com#12345 are not opening this way. What am I doing wrong?


The answer was to add the default category to the second intent filter, just as @advantej suggested.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜