我希望我的意圖在用戶訪問某個網址時啓動:例如,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. Android Volley響應
- 3. android widget無響應
- 4. Android onActivityResult()with Intent
- 5. Android Flavor related Intent
- 6. Android intent image
- 7. Android Intent-filter VerifyError
- 8. ACTION_SEND intent android
- 9. android listview and intent
- 10. android intent putExtras
- 11. android linkify intent
- 12. Android StartAcitivty()with intent
- 13. android讀取USSD響應
- 14. Android Studio響應監聽器
- 15. 上下文intent android
- 16. android intent for sdcard ready
- 17. android intent activity with id
- 18. android intent過濾器?
- 19. 如何從android中的Intent服務中的服務器獲取Json響應?
- 20. Android ListView響應
- 21. 在android應用程序中沒有得到url的響應
- 22. Android Intent使用外部圖像url分享
- 23. 使用Android Intent過濾器匹配URL中的HTTP參數
- 24. Android:調用活動明確使用Intent的Url方案
- 25. 從http.get()得到url響應
- 26. Scrapy得到響應URL
- 27. jQuery檢查url響應
- 28. Android onItemClick事件不響應
- 29. android使用intent with class.forName
- 30. Android intent set getIntExtra as global variable
那裏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