Reputation: 360
I have this code that works fine on other versions of android but seems like its misbehaving on android 6.0.
There is no error as such but the image is not posted.
public void onClick(View v) {
Intent intent = 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(MediaStore.Images.Media.insertImage(getContentResolver(), imagePath, "I am Happy", "Share happy !")));
} catch (FileNotFoundException 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);
}
}
Upvotes: 3
Views: 2145
Reputation: 21
It's because of Instagram permissions. You have to allow storage in: Android settings -> apps -> Instagram -> permissions
Upvotes: 1
Reputation: 360
As Amir suggested, You need to allow permissions to each and every app for every feature. Steps : Android settings -> apps -> select app -> permissions -> allow all those permissions that you want to share.
Upvotes: 1
Reputation: 1180
Probably it is because of android permissions. They have some changes in android 6. Check this link to understand. Go to the device settings>apps and select your app then accept permissions manually and check if your problem is solved.
Upvotes: 0