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.."));
Related
I am very new to this topic how to share my app along with image and text,play store link,my images and text getting from server and image should be not visible after sharing content ,please any one help me how to share this content to other apps like whats app,twitter and more ....
here below my code
File filePath = getFileStreamPath("news_image");
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(filePath));
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_TEXT,
"Here is my IMAGE");
startActivity(Intent.createChooser(shareIntent, "Share IMAGE Using..."))
You should follow the advice from android documentation.
Snippet from the page:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);
So, i was working on this idea where i can let user select an image from a folder when they click on a button and that particular image/images can be send as an attachment using email intent in android. I have been successful in sending one picture or many pictures but the fact is i have to declare those images in my code. I want something like OpenFileDialog which can allow me to choose an image at runtime. Is there a way to do that?
case R.id.button2:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.reccomendation_subject));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, getResources().getString(R.string.recomendation_body));
emailIntent.setType("image/png");
File bitmapFile = new File(Environment.getExternalStorageDirectory()+"/test_1.png");
Uri myUri = Uri.fromFile(bitmapFile);
emailIntent.putExtra(Intent.EXTRA_STREAM, myUri);
startActivity(Intent.createChooser(emailIntent, "Send your email in:"));
break;
I want from my application to send to facebook and other applications an Image and some text so the user can share them. Currently I put the text and the image URI but when I choose facebook only the image is sent. In whatsApp also only the image is sent. In Google+ application both image and text are passed. Can someone show me the right direction?
Code example ( I don't have the original code here with me now, maybe I'll post it later)
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_TEXT , myText);
startActivity(Intent.createChooser(shareIntent, "Choose an app" ));
If I change ACTION_SEND to ACTION_SEND_MULTIPLE then it does not work at all. If I change type to "text/plain" or html then text is sent to whatsapp, google+ and Facebook messenger, but NOT in normal Facebook app ( it opens an empty share dialog).
You should use below lines
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/*");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "My image");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filename_toshare)));// this is for image . here filename_toshare is your file path.
sendIntent.putExtra(Intent.EXTRA_TEXT, "My Image ");// this is for text
startActivity(Intent.createChooser(sendIntent, "Email:"));
hope this helps you.
I've been trying since 2 hours, to find the code to email an image in Android. At least i was successful, but still have a problem. When i email the image, it opens as text file, and not as jpeg. I also used MIME type (image/jpeg), but in vain. Please help me with this.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("image/jpg");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,e2.getText().toString());
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{e1.getText().toString()});
emailIntent.setType("image/jpg");
Uri path = Uri.parse("android.resource://com.mypackage.name/drawable/" + filename);
emailIntent.setType("image/jpg");
emailIntent.putExtra(Intent.EXTRA_STREAM, path);
emailIntent.setType("image/jpeg");
startActivity(Intent.createChooser(emailIntent, "Send Email"));
Any help will be appreciated.
Thank you!
For those who need help, just copy the image to sdcard, and then attach! It works!
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");
emailIntent.setType("application/pdf");
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(emailIntent, "Send email using:"));
Now this works but the problem is that the attachment is called mypdf instead of mypdf.pdf. I cannot figure out how to send it with it's extension... That's what I need help with. Thanks.
I am unconvinced what you want will be possible, since you are pulling the PDF from a resource. If you copy the PDF to a local file (with the correct extension) and send that, you should get the extension in the resulting message. But straight out of the resource...I suspect there's no way to add the extension.
When ever I attempt to use the .putExtra methodology it always crashes my application with a "Force Close" message. If I use something like:
String mtUri = "mailto:someone#gmail.com?subject=Some Subject&body=Some text&";
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(mtUri));
startActivity(intent);
It seems to work fine. I do still have the problem of attaching a file and could use some help figurint out the "attachment=file:///..." syntax.
Thanks,