开发者

how do i launch my app via an email attachment

The following causes the preview butto开发者_开发问答n to show up with the email attachment, and it does in fact launch the app. The problem is now my app shows up as a viewer for items in my Contacts. When you select a contact, you get a "Complete action using" popup with my app listed along with "View contact". Obviously, the mimeType is causing this, but I can't get it to work any other way. The attachment is basically custom data, not intended to opened by any other app.

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="*/*" />
    <data android:path="custom.extension" />
</intent-filter>            


I would add a custom scheme, and then you can use a regular link in your email body...

android:scheme="customSchemeName"


The attachment is basically custom data, not intended to opened by any other app.

That will not work well.

Either:

  • Redesign your application such that your email attachments will reliably be sent with a MIME type (which is determined by the email client, meaning if it is not some universally understood file type, it won't work), or

  • Do not use email attachments, but rather links to files downloaded off the Web, where you can control the MIME type

So, for example, PDFs as email attachments work reasonably well, because most email clients know about PDFs, and therefore send the application/pdf MIME type when they send the attachment.

Once you have solved the problem of getting the MIME type reliably to Android (via the attachment or via the link), then update your <intent-filter> to use that MIME type.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜