I use the code below for sharing images but unfortunately it works only for Line, not for Facebook and Viber
Code:
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/png");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(G.DIR_APP + "/sample_image.png"));
startActivity(Intent.createChooser(share, "Share image"));
Share directly to Facebook and Viber...
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/png");
share.setPackage("com.facebook.katana");
//for viber package is "com.viber.voip".
share.putExtra(Intent.EXTRA_STREAM, ImageUri);
startActivity(p_intent.createChooser(share, "Share With"));
Related
Pinterest Sharing From Android App using Intent is not working,Can somebody help me on this?
Uri bmpUri = Uri.fromFile(imageFileToShare)
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra("com.pinterest.EXTRA_DESCRIPTION", "Messagessssssssss");
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share Image"));
Try this, but you should test if Pinterest is already installed in user's device.
File imageFileToShare = new File(orgimagefilePath);
Uri uri = Uri.fromFile(imageFileToShare);
Intent sharePintrestIntent = new Intent(Intent.ACTION_SEND);
sharePintrestIntent.setPackage("com.pinterest");
sharePintrestIntent.putExtra("com.pinterest.EXTRA_DESCRIPTION", text);
sharePintrestIntent.putExtra(Intent.EXTRA_STREAM, uri);
sharePintrestIntent.setType("image/*");
startActivityForResult(sharePintrestIntent, PINTEREST);
source
I am developing an app in which I want to click Image and automatically after capturing image, the app should send the picture to mail.
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imgSaved));
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share Image"));
You need to create an intent which will be fired on selection of the image
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("application/image");
intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
intent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Any subject you want to give");
intent.putExtra(android.content.Intent.EXTRA_TEXT, "text you want");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/imageYouSelected.jpeg"));
startActivity(Intent.createChooser(emailIntent, "sending youer email"));
OR
You can use the JAVA API approach like here
try like this may help you,
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_EMAIL,
new String[] { "aa#gmail.com" });
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "text of email");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imgSaved));
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share Image"));
I want to upload image to facebook or/and other services, and with , for example, what's up works fine, my picture is send to any contact i choose, but when i pick Facebook on dialog chooser it opens my Facebook App, but says "One or more media items could not be added"
Here is my code how i do it:
String file_path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/image.jpg";
Uri imageUri = Uri.parse(file_path);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpg");
share.putExtra(Intent.EXTRA_STREAM, imageUri);
share.putExtra(Intent.EXTRA_TEXT, "My Image");
startActivity(Intent.createChooser(share, "Share Image"));
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"));
}
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