I have Files in Asset folder , how can i send them using ACTION.SEND intent to Gmail or Other apps exept Facebook (i know how to use JSON)?
i am using this code but it does not work, i have tried so many things , even Attaching File to GMAIL is successful but when sending it , nothing will be post to Gmail account!
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", body);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///android_assets/T1.png");
sendIntent.setType("image/png");
startActivity(sendIntent);
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"test#test.com"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Email subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("<b>Bold message body</b>"));
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:/sdcard/test.txt"));
emailIntent.setType("application/octet-stream");
startActivity(Intent.createChooser(emailIntent, "Send Email"));
Related
We can open share dialog using ACTION_SEND to share text
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Download Link: Android play store link");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Share This App"));
How can I use ACTION_SEND to share a text file.
I read http://developer.android.com/training/sharing/send.html but could not get how to share text file.
Use the following line.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("*/*");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"me#gmail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"go on read the emails");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromfile(new File(yourtextfilepath));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Make sure that your text file path should be from external memory card. Action send wont accept the files from internal memory.
Hope this will help you.
I'm trying to use this solution but Eclipse still cant resolve "Attachment" and "DataService".
I've imported mail.jar and activation.jar, what could I be doing wrong? I've tried countless other sending email solutions on SO/Google but I couldn't get any of them to work with my attachment and send HTML emails.
Any help would be appreciated.
If you need to construct email to be sent by user manually (open his mail program with new email and attachment) you can use this code:
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:" ));
emailIntent.setType("message/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "SUBJECT");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "MESSAGE");
File toAttach = new File("/path/to/your/file");
Uri uri = Uri.fromFile(toAttach);
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(emailIntent);
I used this tutorial and changed
messageBodyPart.setText(_body);
to
messageBodyPart.setContent(_body, "text/html");
I Have sharing image problem with the Gmail Application.
This is my code.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.mail_subject));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.mail_body));
emailIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.facebook_share_text));
//Download the image first
String location=downloadImage(true);
File root=android.os.Environment.getExternalStorageDirectory();
Log.e("send from where:","file:///"+root.getAbsolutePath()+"/"+location);
//Add attachment
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+root.getAbsolutePath()+"/"+location));
emailIntent.setType("image/jpeg");
startActivity(Intent.createChooser(emailIntent, getString(R.string.share_by)));
Default email app is Working great, Facebook Share is working great, Gmail App seams to work but the attachment is not send, although is displayed as attachment.
Here are the screen shots.
So please help.
String location=downloadImage(true);
File root=android.os.Environment.getExternalStorageDirectory();
Log.e("send from where:","file:///"+root.getAbsolutePath()+"/"+location);
//Add attachment
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+
root.getAbsolutePath()+"/"+location));
// replace "Uri.parse" with Uri.fromFile(new File("file:///"+
root.getAbsolutePath()+"/"+location))
emailIntent.setType("image/jpeg");
startActivity(Intent.createChooser(emailIntent, getString(R.string.share_by)));
This thing actually worked for me. Same thing occurs to me, when I sent the Uri.parse. You can see that the size of the attachment will show 0 kb. But when I change it, it worked just fine.
Share image working on facebook,whatsapp,gmail,bluetooth and messages also
Uri imageUri = Uri.fromFile(file);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM,imageUri);
shareIntent.setType("image/*");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent,"Share with.."));
i have to sent image via my application in mail body.
but i am unable to see that image in mail editor. it only shows rectangular box with written "OBJ" inside.
thanx.
I am using the following code.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Product:"+ProductComparisonActivity.s_title);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Title:
"+ProductComparisonActivity.s_title+"\n"+"Description:
"+ProductComparisonActivity.s_des+"\n"+"\n"+"Max Price:
"+ProductComparisonActivity.s_max+"\n"+"Min Price:
"+ProductComparisonActivity.s_min+"\n");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<img src="+"\""+ProductComparisonActivity.image_med+";base64,#IMAGEDATA#"+"\">",imgGetter,null));
// emailIntent.putExtra(Intent.EXTRA_STREAM, ProductComparisonActivity.prod_bmp);
emailIntent.setType("text/html");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Sorry, I don't think it is possible.
In my android, how can I launch android's compose email activity with an attachment attached?
Just launch an intent with the following structure:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"to#example.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "the subject");
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("the content"));
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/file.ext"));
startActivity(intent);
Notice that I'm using the complete path to the file: "file:///sdcard/file.ext". Also, take into account that you can share files that you have saved into the SDCard only (otherwise, the email client will ignore the file).