2010-05-22 38 views
26

我在這裏閱讀(http://androidlittle.blogspot.com/2009/08/intent-filter-for-share-link.html)需要什麼intent-filter來處理android web瀏覽器發送的「共享鏈接」意圖。我在AndroidManifest.xml中放置這樣的一個塊中,像這樣:如何在Android中處理瀏覽器的「共享頁面」意圖?

<activity android:name=".ShareLink"> 
     <intent-filter> 
      <action android:name="android.intent.action.SEND" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:mimeType="text/plain" /> 
     </intent-filter> 
     <meta-data/> 
    </activity> 

我不能爲我的生命得到這個被觸發,雖然。當我在android瀏覽器中共享一個鏈接時,模擬器日誌顯示它正在創建一個選擇器意圖,但沒有給出選擇器正在執行的意圖的詳細信息。沒有選擇器窗口彈出,並且意圖被SMS應用程序處理。

我也試圖手動拉開意圖:

adb shell am start -D -a android.intent.action.SEND -c android.intent.category.DEFAULT -t text/plain -d http://google.com/ 

,但我得到的迴應是:

Starting: Intent { act=android.intent.action.SEND cat=[android.intent.category.DEFAULT] dat=http://google.com/ typ=text/plain } 
Error: Activity not started, unable to resolve Intent { act=android.intent.action.SEND cat=[android.intent.category.DEFAULT] dat=http://google.com/ typ=text/plain flg=0x10000000 } 

誰能告訴我什麼,我做錯了什麼?我的主要(發射器)活動正常,所以我假設在模擬器上安裝沒有問題。

回答

17

哎呦!

原來,我已經安裝了這個軟件包,但重新安裝後,它默默無聞。在這兩個版本之間,我將清單固定爲如上所見 - 安裝的版本沒有指定的意圖過濾器,這顯然不起作用。

猜猜我會在這裏留下以防萬一某人有相同的需要?或者我應該刪除它?

+7

我說離開它,因爲我剛剛找到了我要找的感謝您的帖子。 – 2010-06-28 21:17:26

+3

我也發現這個,發現它很有用,謝謝。 – ksclarke 2011-01-03 22:06:38

+0

好吧,你的問題得到了9個upvotes,你的答案有7個upvotes,並且上面的評論有6個upvotes。我認爲人們已經說過了;) – ajacian81 2011-12-10 13:07:35