How to send/open email attachments from android app?

I would like to somehow send a file from my app on one android device to my app on another device. This can be done any which way, and I'm open to suggestions if you can tell me how to send over network or something like that.

Currently, I'm looking at sending the file as an email attachment, but I haven't found any good documentation on how to do it. I need two things to accomplish this, be able to send my file (stored on sd card or somewhere on device) as an attachment, and have my app recognized by android as the app to open an attachment with the file extention (.lst).

Any thoughts?

The files will all be fairly small xml text files if that makes a difference.


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






Answer 1

I would like to somehow send a file from my app on one android device to my app on another device. This can be done any which way, and I'm open to suggestions if you can tell me how to send over network or something like that.

Write a Web service. Or use Amazon SQS.

be able to send my file (stored on sd card or somewhere on device) as an attachment

As is written up here, you could try:

Intent sendIntent = new Intent(Intent.ACTION_SEND);

sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
sendIntent.putExtra(Intent.EXTRA_STREAM, ...);
sendIntent.setType(...); 

where the first ellipsis is the path to your chosen file and the second ellipsis is a suitable MIME type.

and have my app recognized by android as the app to open an attachment with the file extention (.lst)

Never rely on file extensions. Use MIME types. You can set up an activity with an intent filter that offers ACTION_VIEW support for your MIME type.

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



Answer 2

I did this in order to process vcf files attached to mails and it worked. Here is the intent filer:

        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.VIEW" />
            <data android:mimeType="text/x-vcard" />
        </intent-filter>

See the whole code in http://code.google.com/p/card-catcher.

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



Similar questions

Android multiple email attachments using Intent

I've been working on Android program to send email with an attachment (image file, audio file, etc) using Intent with ACTION_SEND. The program is working when email has a single attachment. I used Intent.putExtra(android.content.Intent.EXTRA_STREAM, uri) to attach the designated image file to the mail and it is working fine, the mail can be delivered through the Gmail. However, when I tried to hav...


email attachments - How can I send an Android app that I'm developing to someone over e-mail?

This is my first Android app. I need to email what I have so far to someone for testing. How should I do I export the app and attach it, so it is not being treated as Junk?


Creating a default viewer / receiver for Android email attachments

I'm trying to create a default handler for .p7s/.p7b files in Android. I figured the best start would be to create a BroadcastReceiver that will capture the intent from the Android email application (or K-9 if that's a need) for opening of certain attachments (filtered by mime type). Specifically I'm trying to handle s/mime email so looking for the "application/x-pkcs7-certificates" and "application/x-pkcs7-certifi...


android - Intent filter for email attachments

I want to open audio attachments in emails with my app. Currently my intent filter is like so: &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW"/&gt; &lt;action android:name="android.intent.action.EDIT" /&gt; &lt;action android:name="android.intent.action.PICK" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;data a...


android - Add menu options to email attachments

Please see the requirement below. For instance, take Astro browser as a template. You might have seen context menu (with menu options such as Open as, Edit, Details and Send), popping up once an item in the list is selected. I want to implement a similar context menu, with different options, when user taps an email attachment irrespective of email clients. Ideally an option would be 'send via bluetooth', allowing t...


java - Missing jar source attachments, thread exceptions, null pointer exceptions, when trying to read from SQLite database on Android

I'm writing an Android project in Eclipse and running it on a 3.1 tablet. When I try to fetch a line from my SQLite database with int Get(long rowId){ System.out.println("Works up to here!!!"); //things are fine Cursor c = myDbHelper.fetch(rowId); //things are not fine ... } I get the following in logcat: Works up to here!!! threadid=9: thread exiting w...


Slideshow for multiple attachments in android messaging application

Please guide me to achieve this : I want to create slideshow for multiple attachment in my messaging application, user can attach image, audio and video files. For single attachment user can view file directly and when user is attaching more files, application should create a playable slideshow and later he can edit the slide show as well, same like messaging application in android. The slide-show f...


couchdb - Android Couchbase - URI for attachments

Some of my couchdb attachments are html files. I want to use those html files in the webview. To do this, I need the complete url to the attachment. How do I get the full path to those attachments? Which APIs should I use. I am using Couchbase library for android and Ektorp Client library. Thanks, Pramod


email - Unable to send Mail with Attachments Android

Friends I am trying to send mail form my application i received this error this is my error: 02-07 15:28:06.852: W/System.err(1051): javax.mail.MessagingException: IOException while sending message; 02-07 15:28:06.852: W/System.err(1051): nested exception is: 02-07 15:28:06.852: W/System.err(1051): javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mix...


android - Attachments in Email

I am developing an app which requires to send email to a person. Everything works fine except the attachment. And here is the piece of code for that emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse( "file://"+Environment.getExternalStorageDirectory()+""+attach)); attach is the file i got by browsing in the phone. But the attachment is not being sent Please Help. Thanx






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



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



top