How to share Image from intent as ACTION_SEND to other app - android

I would to share a picture to other app.I am viewing the image now through get it by intent from other activity.
by this code I get image:
final String imageurl = i.getStringExtra("Image");
And I viewing by Picasso:
Picasso.get().load(imageurl).into(prImg);
Now the question is how to share the displayed image to different applications through the following code:
// Share image
private void shareImage( ) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(sharingIntent, "Share Image Using"));
Or I have to use other code to do it?

Related

How can i share text and image in Android

I want share my application's content (Text and Image) and for this issue, I wrote below codes:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(content) + "" +"\n\n" + "download us app from this link" + "\n\n" +"https://play.google.com/app/com.example.example");
startActivity(Intent.createChooser(sharingIntent, "select app ..."));
But in this code, I can just share text not sharing image! I want to share Text and Image.
For show Text and Image, I use Webview. I show image into text in webview.
How can I share Text and Image?
Below code is useful to share both text and images with other apps.
String imageToShare = "http://s1.dmcdn.net/hxdt6/x720-qef.jpg"; //Image You wants to share
String title = "Title to share"; //Title you wants to share
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, title);
shareIntent.setType("*/*");
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_TEXT, imageToShare);
startActivity(Intent.createChooser(shareIntent, "Select App to Share Text and Image"));
See below Code,
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_TEXT,"http://lorempixel.com/400/200/sports/1/");//your Image Url
startActivity(Intent.createChooser(intent, "Share Image"));
Add the URI of your image to the bundle (e.g. http://some.server.com/your_image.png), this will allow the same image to be found & used when the data is pulled out of the bundle.

How to share Image with some text using Intent code either on FB,Twitter in Android?

I have written this code and its successfully working its sending only content and it can share via FB,BlueTooth etc.But i want to share image as well.User will click on image and then share button and save button will be shown.Now when user click on "share button" the clicked image must be share as Bluetooth,FB,Twitter etc.I have written this code its working for text please let me know how can i send image as well and images are inside the project folder #drawable folder....
public void shareApp()
{
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
//setting MIME type for Sharing Content
sharingIntent.setType("text/plain");
sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
String shareBody = "Here is the share content body";
sharingIntent.putExtra(Intent.EXTRA_EMAIL,new String[] {"abc32#yahoo.com"});
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
}

sharing photo from android app

I have developed one wallpaper application in which I want to add share button to share a photo on whatsapp. Here is my code( but that code is only for any text msg) I want to share a photo.
Please respond with the code where in I can select a wallpaper from my application and send to whatsapp's particular contact.
case R.id.save:
InputStream y11 = getResources().openRawResource(to);
Bitmap b11 = BitmapFactory.decodeStream(y11);
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("image/*");
waIntent.setPackage("com.whatsapp.android");
waIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, to);
startActivity(Intent.createChooser(waIntent, "Share with"));
Replace
waIntent.setType("text/plain");
with
waIntent.setType("image/png");
the package name is wrong. try: com.whatsapp
and this code is to share image via whatsapp
private void shareIt(Uri uri) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/*");
sharingIntent.setPackage("com.whatsapp");
sharingIntent.putExtra(Intent.EXTRA_TEXT,"Shared via my app");
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(sharingIntent, "share with"));
}

Sharing image on facebook via Intent in eclipse

I am using the following code to share image to facebook but its not working.
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/png");
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse("/sdcard/img1.png"));
startActivity(Intent.createChooser(share, "Share Image"));
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"));
One, it should be in this order just for readability and sensical reasons
you need to say what the error is...
NEVER hardcode the path to the image '/sdcard/img1.png' use getExternalStorageDirectory() instead

Android need to share Image and text together all social medias

need to share Image and text together all social medias I used this it only share the image on facebook
// Intent sharingIntent = new Intent(Intent.ACTION_SEND);
// Uri path = Uri.parse("android.resource://com.hunter99x/" + R.drawable.ninexgreen);
// Uri screenshotUri = Uri.parse(path.toString());
// sharingIntent.setType("image/*");
// sharingIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
// sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
// startActivity(Intent.createChooser(sharingIntent, "Share image using"));

Categories

Resources