2011-01-10 31 views
2

我想用我的應用程序在電子郵件中打開音頻附件。目前我的意圖過濾器是這樣的:電子郵件附件的意圖篩選器

<intent-filter> 
     <action android:name="android.intent.action.VIEW"/> 
     <action android:name="android.intent.action.EDIT" /> 
     <action android:name="android.intent.action.PICK" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <data android:mimeType="audio/wav" /> 
     <data android:scheme="http" android:host="*" android:pathPattern=".*\\.wav"/> 
     <data android:scheme="https" android:host="*" android:pathPattern=".*\\.wav"/> 
     <data android:scheme="content" android:host="*" android:pathPattern=".*\\.wav"/> 
     <data android:scheme="file" android:host="*" android:pathPattern=".*\\.wav"/> 
</intent-filter> 

這適用於我想要的一切,除了電子郵件附件。目前,如果我發送了一個wav文件,我可以做的唯一事情就是預覽它,並打開Winamp(很明顯,第三方應用程序有辦法進入)。我找不到應該添加什麼來做這件事,有沒有人有任何想法?

編輯

這裏是logcat的有就此事說。當我點擊預覽時我得到

01-10 19:28:52.691: INFO/ActivityManager(109): Starting: Intent { dat=content://gmail-ls/messages/xxxxxxx%40gmail.com/439/attachments/0.1/BEST/false cmp=com.google.android.gm/.ViewAttachmentActivity } from pid 19483 

奇怪的是Winamp會自動打開,並且不會被設置爲默認值。我沒有選擇...

+0

我肯定知道的唯一的事情是,附件內容提供商不使用的文件名,但一些字母數字代碼,這樣的* .wav過濾器不適合這項工作。應該使用mimetype。 – bigstones 2011-01-10 18:19:51

+0

我已經有``在那裏,有沒有另外一種方法我應該這樣做? – fredley 2011-01-10 18:21:47

+0

不知道...我有這個``for xml,它工作。 (category = default,action = view) – bigstones 2011-01-10 18:44:56

回答

0

電子郵件客戶端似乎以任意方式選擇mimetypes作爲附件,因此意圖過濾器打開它們必須考慮到所有可能性。搜索互聯網有助於找到所有可能的類型,如果不需要像audio/*這樣的通配符(如OP says),則應爲每個類型添加一個<data/>篩選器。

無論如何,通過MIME類型濾波建議作爲比由文件擴展名過濾之外的第一選擇(見this thread上機器人-dev的毫升)。

(感謝fredley)

2

替換audio/wavaudio/*使它的工作,但是這顯然是不受歡迎的行爲。