Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to show an image through an intent being compatible with different apps
    text
    copied!<p>I'm trying to share an image I have previously saved on disk, sending an <code>Intent.ACTION_SEND</code>. The problem is that I can't find a way to be compatible with different apps, official Gmail app and TweetDeck in my case. </p> <p>The image I want to share is contained in a <code>File</code>:</p> <pre><code>File agendaFile; // its path using getAbsolutePath() -&gt; /data/data/com.mypackage/files/agenda.jpg </code></pre> <h1>Option A) using Uri.fromFile</h1> <pre><code>Uri agendaUri = Uri.fromFile(agendaFile); // the value -&gt; file:///data/data/com.mypackage/files/agenda.jpg </code></pre> <h2>Results</h2> <ul> <li>Gmail, is the image attatched to the email? <strong>NO</strong></li> <li>Tweetdeck, is the image added to the tweet message? <strong>YES</strong></li> </ul> <h1>Option B) using Uri.parse</h1> <pre><code>Uri agendaUri = Uri.parse(agendaFile.toURI().toString()); // the value -&gt; file:/data/data/com.mypackage/files/agenda.jpg </code></pre> <h2>Results</h2> <ul> <li>Gmail, is the image attatched to the email? <strong>YES</strong></li> <li>Tweetdeck, is the image added to the tweet message? <strong>NO</strong></li> </ul> <h1>Finally</h1> <p>In both cases I send the intent like this:</p> <pre><code>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")); </code></pre> <p>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?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload