I have in my app a share button and i want to share an image and a text at the same time. In GMail it works fine but in WhatsApp, only the image is sent and in Facebook the app crashes.
The code i use to share is this:
Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_TEXT, "Message"); Uri uri = Uri.parse("android.resource://" + getPackageName() + "/drawable/ford_focus_2014"); try { InputStream stream = getContentResolver().openInputStream(uri); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
If I use "shareIntent.setType("*/ *")" Facebook and WhatsApp crashes.
Is there some way to do this? Maybe sent two messages by separate at the same time (WhatsApp).
Thanks in advance.
Steps to Send Picture or Message from Facebook to WhatsAppFrom your Android or iOS device, open the Facebook App. Now you may upload any image or text. You may also share a friend's public postings. After it has been uploaded, select the Share option.
Currently Whatsapp supports Image and Text sharing at the same time. (Nov 2014).
Here is an example of how to do this:
/** * Show share dialog BOTH image and text */ Uri imageUri = Uri.parse(pictureFile.getAbsolutePath()); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); //Target whatsapp: shareIntent.setPackage("com.whatsapp"); //Add text and then Image URI shareIntent.putExtra(Intent.EXTRA_TEXT, picture_text); shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri); shareIntent.setType("image/jpeg"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); try { startActivity(shareIntent); } catch (android.content.ActivityNotFoundException ex) { ToastHelper.MakeShortText("Whatsapp have not been installed."); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With