18

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"));
chiragkyada
  • 3,585
  • 3
  • 17
  • 18
hosseinAmini
  • 2,184
  • 2
  • 20
  • 46
  • and how is that suppose to work for `facebook` – ashishmaurya May 25 '14 at 13:50
  • can you let me know what is complete path here of the bitmap ? – Ajay S May 25 '14 at 13:52
  • 1
    facebook app open but image doesn't display – hosseinAmini May 25 '14 at 16:39
  • Isn't this a duplicate of [this](http://stackoverflow.com/questions/13505279/sharing-content-on-facebook-android)? – Fernando Carvalhosa May 27 '14 at 00:53
  • Anyway, some guy pointed this out [here](http://stackoverflow.com/questions/9730243/android-how-to-filter-specific-apps-for-action-send-intent): "Facebook IGNORES our text. They say "These fields are intended for users to express themselves. Pre-filling these fields erodes the authenticity of the user voice." One workaround is to use the Facebook SDK to post, but that doesn't allow the user to choose how they want to share. We can also make a custom landing page, and the link will show the text from that page with our link in Facebook." – Fernando Carvalhosa May 27 '14 at 00:53

1 Answers1

2

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"));
chiragkyada
  • 3,585
  • 3
  • 17
  • 18