我希望我的意圖在用戶訪問某個網址時啓動:例如,Android市場可以通過http://market.android.com/這個網址進行操作。 youtube也一樣。我也希望我也這樣做。Android響應URL Intent
146
A
回答
183
我做到了!使用<intent-filter>
。將以下內容放入清單文件中:
<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:host="www.youtube.com" android:scheme="http" />
</intent-filter>
這很好用!
7
您可能需要爲您的意圖過濾器添加不同的排列,以使其在不同情況下(http/https/ect)可以工作。
例如,我不得不做以下的應用程序,當用戶打開一個鏈接到谷歌驅動形式這將打開,www.docs.google.com/forms
注意路徑前綴是可選的。
<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:host="docs.google.com"
android:pathPrefix="/forms"/>
<data
android:scheme="http"
android:host="www.docs.google.com"
android:pathPrefix="/forms" />
<data
android:scheme="https"
android:host="www.docs.google.com"
android:pathPrefix="/forms" />
<data
android:scheme="https"
android:host="docs.google.com"
android:pathPrefix="/forms" />
</intent-filter>
相關問題
- 1. 用Intent獲取url Android
- 2. 如何獲得每個響應任何URL/URI-Intent的App/Activity?
- 3. Android Intent過濾器URL路徑包括#
- 4. Android Volley響應
- 5. android widget無響應
- 6. Android onActivityResult()with Intent
- 7. android linkify intent
- 8. nullpointer on intent android
- 9. Android StartAcitivty()with intent
- 10. Android Intent-filter VerifyError
- 11. Android ViewPageIndication with intent
- 12. Android Flavor related Intent
- 13. android intent putExtras
- 14. android listview and intent
- 15. Android ViewFlipper With Intent
- 16. ACTION_SEND intent android
- 17. android listview intent
- 18. Android intent image
- 19. Android Intent to Amazon應用程序
- 20. Android:沒有對話響應
- 21. android讀取USSD響應
- 22. Android Studio響應監聽器
- 23. android intent call without inquiry
- 24. Android Intent for google.maps onclick
- 25. android intent過濾器?
- 26. android intent activity with id
- 27. Android Intent not calling class
- 28. 上下文intent android
- 29. android intent for sdcard ready
- 30. 如何從android中的Intent服務中的服務器獲取Json響應?
那裏http://stackoverflow.com/questions/2448213/how-to-implement-my-very-own-uri-schema-on-android/2448531#2448531 – neu242 2010-06-24 06:11:29
是一個很好的回答這個問題有一個更好的答案這個問題http://stackoverflow.com/questions/1609573/intercepting-links-from-the-browser-to-open-my-android-app – rds 2012-09-16 15:05:22