문제

I want to open audio attachments in emails with my app. Currently my intent filter is like so:

<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>

This works for everything I want it to except for email attachments. Currently if I'm sent a wav file, the only thing I can do is preview it, and that opens with Winamp (so clearly 3rd party apps have a way in). I can't find what I should be adding to do this though, does anyone have any idea?

Edit

Here's what LogCat has to say on the matter. When I click Preview I get

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

What's bizarre is that Winamp automatically opens, and is not set as default. I'm given no choice...

도움이 되었습니까?

해결책

email clients seem to choose mimetypes for attachments in an arbitrary way, so intent filters to open them must contemplate all possibilities. searching the internet helps to find all the possible types and one should add a <data/> filter for each of them, if a wildcard like audio/* is not desired (as OP says).

anyway, filtering by mimetype is suggested as a first choice other than filtering by filename extension (see this thread on android-dev ml).

(thanks fredley)

다른 팁

Replacing audio/wav with audio/* makes it work, however this is obviously undesirable behaviour.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top