Reputation: 2079
I need to share text+image via Facebook, email etc. Now, I use this code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.settings_share_text));
//Uri path = Uri.parse("android.resource://com.android.mypackage/" + R.drawable.arrow);
Uri path = Uri.parse("android.resource://com.android.mypackage/drawable/arrow.png");
intent.putExtra(Intent.EXTRA_STREAM, path );
Intent mailer = Intent.createChooser(intent, null);
startActivity(mailer);
The problem is that when I use "arrow.png", it says "Couldn't show attachment" and doesn't attach image; when I remove .png, I cannot open attached file later. Basically, I need to attach png from drawable and some text and share it via ACTION_SEND
Upvotes: 3
Views: 3469
Reputation: 8745
Try to use
Uri.fromFile(new File("android.resource://com.android.mypackage/drawable/arrow.png"));
insted of
Uri.parse("android.resource://com.android.mypackage/drawable/arrow.png");
It will work fine if file descriptor will be valid.
Upvotes: 3