參考:
http://blog.csdn.net/annkie/article/details/8349626
http://xiechengfa.iteye.com/blog/1004991
BROWSABLE的意思就是瀏覽器在特定條件下可以打開你的activity:
舉例1:
我有一個activity,它注冊了能顯示pdf文檔,AndroidManifest.xml內容如下:
<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:mimeType="application/pdf"/> </intent-filter>
你在瀏覽器中輸入 http://www.devdiv.com/1.pdf ,那么這個activity自動被瀏覽器給調起來。
類似我們注冊了一個數據類型,指定默認打開這個數據類型的應用程序
舉例2: 開源中國的
<activity android:name=".ui.MainActivity" android:launchMode="singleTask" android:screenOrientation="portrait"> <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:host="www.oschina.net" android:scheme="http" /> </intent-filter> <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:host="www.oschina.net" android:scheme="https" /> </intent-filter> <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:host="my.oschina.net" android:scheme="http" /> </intent-filter> <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:host="my.oschina.net" android:scheme="https" /> </intent-filter> </activity>