How do I ensure that the email app will use my app

2019-07-20 23:56发布

问题:

I'm currently building an app that allows you to load files from emails and export created ones using email. The extension is .lq. I am currently using this intent filter however I repeatedly get the error 'This attachment cannot be displayed' in the standard email app when attempting to open something with the extension .lq:

<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="file"/>
    <data android:mimeType="*"/>
    <data android:pathPattern=".*\\.lq"/>
    <data android:host="*"/>
</intent-filter>

I've tried a number of different solutions however none of them have worked.

回答1:

You can use the Intent Intercept application to analyse the Intent sent by your mail app and know what intent filter you need to create.

From the gmail app, i get the following intent :

Action : android.intent.action.VIEW

Data : content://gmail-ls/myemail@gmail.com/messages/471/attachements/0.1/BEST/false

URI : content://gmail-ls/myemail@gmail.com/messages/471/attachements/0.1/BEST/false

Type : image/png

So the problem is that your .lq is not a standard extension, and you can't rely on the file name to end with .lq either, as it uses an internal name without extension.

You could use an intent filter to catch content://* URIs.



回答2:

I also had this problem. Try to completely remove mimetype attribute.