I have a list of Drawable images in my application and want to send one of the images through mail.
my code looks like
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/*");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Picture");
sendIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse(lstPhotos.get(newPosition).getPhotoURL()));
myActivity.startActivity(Intent.createChooser(sendIntent, "Email:"));
But in the above code i have a problem since i cannot get the image URI from the list of drawables.
Can anyone help me how to send the image because if i use the above code i am getting an empty image of 0kb sent.
You can do it by saving that image to a temporary location on internal/external cache directory as an image and then use that image's path in the attachment using Uri.
Related
Actually I am getting all rss feed from here
Now I all complete with my code But I want to add one functionality of share image.
Now I have image linke for ex.
http://miscmedia-9gag-lol.9cache.com/images/long-post-cover/12796580_1414746906.7976_Ejy2yj_460c.jpg link
How can I share this image like sharing an regular image.
I solved such issue by downloading image before sharing. (If you display images in your app using library like universal image loader or implemented such functionality on your own the only thing you need to do is to find predownloaded image on file system) If image is not large it will not take much time to download. Then you can delete image file after sharing.
try this,
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, imageurl);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share images to..");
I want to attach image from resource/drawable folder to MMS.Is it possible to attach image from drawable folder to MMS.if yes then please provide me some code here.I tried a lot and also found a lot here on So as well as on Google but still not able to get the right solution yet.Please some one help me for my this issue.Thanks in Advance.My code is as:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/png");
sendIntent.putExtra("sms_body",
getResources().getText(R.string.Message));
File f = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath(), "koala.jpg");
Uri uri = Uri.fromFile(f);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(sendIntent, ""));
You can achive this in following steps
First get the bitmap of image from your drawable
Then save that bitmap to SDcard
Then give that sdCard file path to you sendIntent
I want the image that the user made to be shared when he clicks on the button
the image is an image he made using many features like paint etc ..
I want when he clicks on the sharing button a sharing intent "share via."
appears and let him choose where he wants it to be shared at
I found this code but I get an error from (path)
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(path);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
How can I do this?
What do you put in the variable path?
Path is the route to the file where you have saved the bitmap previously (sdcard or internal app storage).
It's right that the picture must be saved first, but If you are not saving it now, how do you fill path variable?
Hi i am making an app in which i am dynamically getting the image from server and i want to give user the option to mail that image. I am using following code but i dont how to set path of image in below code.
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);
You set the path to the image in this line:
emailIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://"+file.getAbsolutePath()));
, where file is the image you want to send.
Also, note that the second call to setType will override the effects of the first call you made.
How can I know filename of ImageView image?
I want to send it as email attachment.
UPDATE: I don't use images from resources. I have images from android storage(as in contacts app) using:
new Intent(Intent.ACTION_GET_CONTENT, null);
and from camera. Camera is OK - I can get filepath. But storage is question
If the image is a resource that you provide then you can get the path to the image. The format is:
"android.resource://[package]/[res id]"
[package] is your package name
[res id] is value of the resource ID, e.g. R.drawable.example
You can then pass this as an extra in your create e-mail intent like this:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
//Mime type of the attachment (or) u can use sendIntent.setType("*/*")
sendIntent.setType("image/jpeg");
//Subject for the message or Email
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "My Picture");
//Full Path to the attachment
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://your.package.name/" + R.drawable.example));
//Use a chooser to decide whether email or mms
startActivity(Intent.createChooser(sendIntent, "Email:"));
The short answer is that you can't, as images can be from a variety of sources. What you can do is get the bitmap cache with the same result of sending the image.