I'm having troubles sharing an image from my app to other apps.
The problem is when I share the image, it doesn't include the extension and other apps like messenger, whatsapp or gmail doesn't recognise them.
My code is:
Intent intent = new Intent(Intent.ACTION_SEND);
String path = "android.resource://com.xxxx.xxxxxxx/drawable/image";
Uri screenshotUri = Uri.parse(path);
intent.putExtra(Intent.EXTRA_TEXT, "Hello world!");
intent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
intent.setType("image/*");
startActivity(Intent.createChooser(intent, "Share:"));
I'm having the same problem sharing audio:
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
String sharePath = "android.resource://com.xxx.xxxxx/raw/" + sound;
Uri uri = Uri.parse(sharePath);
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setType("audio/mp3");
Intent i = Intent.createChooser(share, "Share Sound File");
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
baseContext.startActivity(i);
I already checked the official documentation and still having problems: https://developer.android.com/training/sharing/send.html
Thanks for help or any hints!