你如何抓住打开网页的意图?

Cli*_*ive 4 android

我试图捕捉当有人点击Mms浏览器中的网页超链接时触发的意图.我在清单中有这个:

        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="http" />
        </intent-filter>
Run Code Online (Sandbox Code Playgroud)

但是,当我点击http://www.ibm.com时,它只启动浏览器.当我 在adb shell中启动-a android.intent.action.VIEW -d http://www.ibm.com时也一样.我有什么想法我做错了吗?

非常感谢,c

Tim*_*ger 6

浏览器的清单中复制intent-filter行,它将起作用:

        <!-- For these schemes were not particular MIME type has been
             supplied, we are a good candidate. -->
        <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" />
            <data android:scheme="https" />
            <data android:scheme="about" />
            <data android:scheme="javascript" />
        </intent-filter>
        <!--  For these schemes where any of these particular MIME types
              have been supplied, we are a good candidate. -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="http" />
            <data android:scheme="https" />
            <data android:scheme="inline" />
            <data android:mimeType="text/html"/>
            <data android:mimeType="text/plain"/>
            <data android:mimeType="application/xhtml+xml"/>
            <data android:mimeType="application/vnd.wap.xhtml+xml"/>
        </intent-filter>
Run Code Online (Sandbox Code Playgroud)