I want to allow the user to share a saved image (image is in mipmap folder and name is banner) with a text on Whats App through my app. I am using the given code but this code is crashing the app. Can someone please see where I am going wrong.
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.app_name) +
"\nCreated By : " + getResources().getString(R.string.app_link));
sharingIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(),
BitmapFactory.decodeResource(getResources(), R.mipmap.banner), null, null)));
startActivity(Intent.createChooser(sharingIntent, "Share App using"));
break;
Related
I know how to share normal text with an image but I want to share an html link with the image. If the user will share it and the second user will click on the link it will open a particular activity on the app.
What I've tried so far
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
String textToShare = "Check out " + service_provider.businessName + "";
share.putExtra(Intent.EXTRA_TEXT, textToShare);
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:///sdcard/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
This just sends the text as a normal plain text.
Hi I want to share both text and pdf file at a time in whats app,How it can be done.currently i can share any one of them at a time.
I have tried this but its not working.
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
share.setType("application/pdf");
share.putExtra(Intent.EXTRA_TEXT, "My sample image text");
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setPackage("com.whatsapp");
startActivity(shareIntent);
I can use below code for share sticker to Viber. But after share sticker background become to black.My sticker is Transparent.Please help me.
My screen short image link
Here is my source code:
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/sticker_demo/" +transparentstickerpath));
startActivity(Intent.createChooser(sharingIntent, "Share via"));
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 want to share a image that is in my own application and I do so with the following code:
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://"package"/drawable/" + card_name));
shareIntent.setType("image/jpg");
startActivity(Intent.createChooser(shareIntent, getString(R.string.share_app_via)));
Far without problems, but if I send the image to the email and download it, the image has no extension.jpg and therefore can not be opened.
How I can do to put jpg extension to image?
Did you try putting .jpg at the end of card_name
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://"package"/drawable/" + card_name + ".jpg"));