I am using a sharing functionality to social application using Intent
.
I have a problem with sharing an image in Instagram.
Some times I get the message
Unable to load Image.
Here is my code:
String path="content://media/external/images/media/32872";
Intent shareIntent = new Intent();
shareIntent.setType("image/jpeg");
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(path));
shareIntent.setPackage("com.instagram.android");
startActivity(shareIntent);
How do I get rid of this problem?
if you have file then use below code to share image,
private void shareIntagramIntent(String path) {
Intent intent = getActivity().getPackageManager()
.getLaunchIntentForPackage("com.instagram.android");
if (intent != null) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setPackage("com.instagram.android");
try {
shareIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file://" + path));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
shareIntent.setType("image/jpeg");
startActivity(shareIntent);
} else {
// bring user to the market to download the app.
// or let them choose an app?
intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("market://details?id="
+ "com.instagram.android"));
startActivity(intent);
}
}
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