Andriod Studio:建立一个活动,能响应打开网页的Intent

《第一行代码》中有一个示例,让自己的Activity响应http的action,但却编译不通过:

Andriod Studio:建立一个活动,能响应打开网页的Intent

Andriod Studio:建立一个活动,能响应打开网页的IntentAndriod Studio:建立一个活动,能响应打开网页的Intent

Andriod Studio:建立一个活动,能响应打开网页的Intent

错误提示:没有将activity设置为browsable。

但因为category可以指定多个,这里添加一个browsable的category就可以:

        <activity android:name=".ThirdActivity">
            <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"/>
            </intent-filter>
        </activity>