How to open email attachment in my app on android?

I want to open a specific type of file that my app can already send over email as an attachment. I need to be able to have the android email app choose my app to download or open that specific file type. I can't figure out how to set up an intent filter that would let me do that though. Anyone know how this is done?


Asked by: Chelsea219 | Posted: 20-01-2022






Answer 1

Intent filters generally work based on MIME type of the file. But if you're using a custom file format that Android's not likely to recognise, then it's not as simple. You can maybe try using the android:pathPattern attribute to try and match the filename, but it's not something I've tried.

I imagine you'd use something like this in your <activity> tag:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="*/*" />
    <data android:pathPattern=".*\\.xyz" />
</intent-filter>

Answered by: Audrey778 | Posted: 21-02-2022



Similar questions

Read data from an Android USB attachment

Is there anyway to read data from an attachment through the USB port on an Android device? In particular, an EKG. Most the work can be done by the hardware of the device to simplify the output to a single number, a voltage reading. If its not possible, what about modifying an accessory that can already communicate with an android device? Thinking of devices that attach to android phones, what about sending the data as an a...


Read data from an Android USB attachment

Is there anyway to read data from an attachment through the USB port on an Android device? In particular, an EKG. Most the work can be done by the hardware of the device to simplify the output to a single number, a voltage reading. If its not possible, what about modifying an accessory that can already communicate with an android device? Thinking of devices that attach to android phones, what about sending the data as an a...


What is the E-mail Attachment limitation in android?

I wanted to know what is the maximum size of the file that we can attach with e-mail in android? Or is the attachment limit completely dependent on E-mail that we have configured ???


Give alert when the file is download from the attachment in android

I download the *.ics file successfully from the mail attachment by using intent-filter. I need to give an alert at the time of downloading the ics file. How to do this? Please help me to solve.This I am new to android.


android - Read mail Attachment files in Android2.1?

I configure email by using the android2.1 emulator. When I download the files from mail attachment I get the path content://com.android.email.attachmentprovider/1/1/RAW I need to read that file data. How to read the data from the device.?? Is there any permission to read file from the phone memory. My code is here: intent = getIntent(); String str_sel_fname=intent.getDataS...


android - How to open ICS file from mail attachment in own app?

I use the following manifest file: &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;data android:mimeType="text/calendar" /&gt; &lt;data android:pathPattern="\\*.ics" /&gt; &lt;/intent-filter&gt; &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission ...


android - can not install apk from email attachment to phone getting parsing error

I have built a test android app and signed it successfully and then sent it to someone to test via email. They click on the attachment in the email on their android phone and get a parsing error. They have 2.1 android the test app was built using 2.2 would that cause an issue? can email attachments of apk files not be installed directly to the phone?


How can I launch android's email activity with an attachment attached in the email?

In my android, how can I launch android's compose email activity with an attachment attached?


email - How to add .pdf extension when sending an attachment from Android?

I am trying to send a pdf as an attachment from Android. Here is the code: String[] mailto = {"me@gmail.com"}; Uri uri = Uri.parse("android.resource://com.mywebsite.sendemail/raw/mypdf"); Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL, mailto); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "My Subject"); emailIntent.putExtra(Intent.EXTRA_TEXT, "My Body"); emailInt...


Android Gmail attachment

I'm trying to get the name of the file attached to an email on the gmail app? Can anyone point in the direction of getting the file name ? I can get the attachemnt, just don't know how to get the original file name.


email - Sending PNG attachment via Android GMail app

I'm attaching a PNG image to an e-mail with the following code: ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, title); values.put(MediaStore.Images.Media.DESCRIPTION, title); values.put(MediaStore.Images.Media.MIME_TYPE, "image/png"); Uri uri = activity.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); OutputStream stream = activity.get...






Still can't find your answer? Check out these communities...



Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android



top