Как показать изображение через намерение быть совместимым с различными приложениями
Я пытаюсь поделиться ранее сохраненным на диске изображением, отправляяIntent.ACTION_SEND
, Проблема в том, что я не могу найти способ быть совместимым с различными приложениями, официальным приложением Gmail и TweetDeck в моем случае.
Изображение, которым я хочу поделиться, содержится в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
В обоих случаях я отправляю намерение так:
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"));
Итак, есть ли другие варианты поделиться изображением? Как лучше всего делиться изображением, совместимым с большинством приложений?
Спасибо!