I'm trying to share an image I have previously saved on disk, sending an Intent.ACTION_SEND
. The problem is that I can't find a way to be compatible with different apps, official Gmail app and TweetDeck in my case.
The image I want to share is contained in a File
:
File agendaFile;
// its path using getAbsolutePath() -> /data/data/com.mypackage/files/agenda.jpg
Option A) using Uri.fromFile
Uri agendaUri = Uri.fromFile(agendaFile);
// the value -> file:///data/data/com.mypackage/files/agenda.jpg
Results
- Gmail, is the image attatched to the email? NO
- Tweetdeck, is the image added to the tweet message? YES
Option B) using Uri.parse
Uri agendaUri = Uri.parse(agendaFile.toURI().toString());
// the value -> file:/data/data/com.mypackage/files/agenda.jpg
Results
- Gmail, is the image attatched to the email? YES
- Tweetdeck, is the image added to the tweet message? NO
Finally
In both cases I send the intent like this:
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("image/jpg");
intent.putExtra(android.content.Intent.EXTRA_STREAM, agendaUri);
startActivity(Intent.createChooser(intent, "title"));
So, is there any other options to share an image? How is it the best way to share an image being compatible with most apps as possible?
Thanks!