I'm trying to make an application to capture an image and send it by email, I successfully made it by the following code
String path = Images.Media.insertImage(getContentResolver(), bmp,"title", null);
Uri screenshotUri = Uri.parse(path);
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent
.putExtra(android.content.Intent.EXTRA_EMAIL, emailAddresses);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
emailIntent.setType("image/png");
startActivity(Intent.createChooser(emailIntent, "Send email using"));
But the image is sent in a small size and very low resolution ?! Any suggestions for sending the image with it's actual size and resolution ?! Or is there any other way to get a jpeg image from the camera result instead of a bitmap ?!
Thanks in advance
bmp is a Bitmap I assume? Then you can save the image by use the compress http://developer.android.com/reference/android/graphics/Bitmap.html#compress%28android.graphics.Bitmap.CompressFormat,%20int,%20java.io.OutputStream%29 method from the bitmap class to write it to a file, and then create a Uri from the file.
When you insert an image, the Uri you receive from Media can be a reduced version.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, EMAIL_SUBJECT);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, EMAIL_TEXT);
File newFile = new File(Environment.getExternalStorageDirectory(), IMAGE_PATH);
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.fromFile(newFile));
startActivity(emailIntent);
Related
I would like to make a share button for both gmail and the rom email app . The problem is how to share both image and text?
For the image , I can provide either file uri / bitmap / whatever need and I only need to share one image.
final Intent result = new Intent(android.content.Intent.ACTION_SEND);
result.setType("plain/text");
result.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { recipient });
result.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
result.putExtra(android.content.Intent.EXTRA_TEXT, body);
Thanks for helping
You can find ans from below code:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("image/jpeg");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {""});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, EMAIL_SUBJECT);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, EMAIL_BODY);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+fileName));
startActivity(Intent.createChooser(emailIntent, "Sharing Options"));
Hope this helps..
I am developing an application in which i have to send an image via email, I tried with
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "xyz#gmal.com");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "message");
emailIntent.setType("image/png");
ArrayList<Uri> uris = new ArrayList<Uri>();
uris.add(Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.a));
emailIntent.putExtra(Intent.EXTRA_STREAM, uris);
startActivity(emailIntent);
but its giving me as gmail has stopped unfortunately.How can I send an image via email,
Thanks in advance.
Get the image storage path by using the file,
File img = new File(Environment.getExternalStorageDirectory()+"/Android/data/"+getApplicationContext().getPackageName()+"/", imagename+".png");
Convert that file path in to Uri
Uri imageuri = Uri.fromFile(img);
Send the image via email using
Intent send_img = new Intent(Intent.ACTION_SEND);
send_img.putExtra(Intent.EXTRA_EMAIL, "xyz#gmal.com");
send_img.putExtra(Intent.EXTRA_SUBJECT, "email_subject");
send_img.putExtra(Intent.EXTRA_STREAM, imageuri);
send_img.putExtra(Intent.EXTRA_TEXT, "message");
send_img.setType("text/plain");
send_img.setType("image/png");
startActivity(Intent.createChooser(send_img, "Send Email..."));
I know this question is already ask in the stack overflow, and I looked around them but don't get any clue. Actually I have written code for sending an image file as an attachment to my mail and its working fine. The code I used for sending an image file as an attachment is shown below. Can anyone tell me what are the changes I need to do to send the image file in the body of mail? Any clue will be helpful.
Code for sending the image as an attached file
Uri imageUri = Uri.parse("content://" + CachedFileProvider.AUTHORITY + "/" + fileNameArray.get(position));
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("image/png");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(i, "Send email"));
only work in device not in android emulator..
http://blogingtutorials.blogspot.com/2010/12/send-email-with-attached-file-in.html
Try using the following intent:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("image/jpeg");
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");
Log.v(getClass().getSimpleName(), "sPhotoUri=" + Uri.parse("file:/"+ sPhotoFileName));
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ sPhotoFileName));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Intent emailIntent = new Intent(Intent.ACTION_SEND);
Uri U=Uri.parse("c:/logo.png"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,"sivafarshore#yahoo.com");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is email's message");
emailIntent.setType("image/png");
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,U);
startActivity(Intent.createChooser(emailIntent, "Email:"));
I am using this kind of coding for attach image file,this code sent attach with email,but that attach file dose not contain no image,what can i do for display attach image file.
Hey... it seems you are trying to attach something that is inside your C: drive. That's not possible :) You can only attach images on the sdcard folder of the handset. For instance:
Intent emailIntent = new Intent(Intent.ACTION_SEND);
Uri U=Uri.parse("file:///sdcard/logo.png");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,"sivafarshore#yahoo.com");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is email's message");
emailIntent.setType("image/png");
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,U);
startActivity(Intent.createChooser(emailIntent, "Email:"));
To know where the sdcard folder is mounted, you use the Environment.getExternalStorageDirectory() method.
i can pick a image and its path using intent. with the use of that path of an image. i have to set that image as attachment of the mail's body content. how its possible in android???
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,getResources().getString(R.string.emlSendToFriendSubject));
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{emailto});
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,getResources().getString(R.string.emlSendToFriendBody));
File file = getFileStreamPath(EMAIL_TEMP_FILE);
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
emailIntent.setType("image/jpeg");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+file.getAbsolutePath()));
startActivityForResult(Intent.createChooser(emailIntent, getResources().getString(R.string.btnSendToFriend)),ActMain.EMAIL_DONE);