I got some .mp4 files in my /raw folder which i want to share with the Android Share. The following code works with Facebook Messenger (the video is sended) but not with other applications like WhatsApp, Gmail, Facebook, etc.
I got the following code:
String path = "android.resource://com.my.package/raw/" + "name_mp4";
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("video/mp4");
share.putExtra(Intent.EXTRA_STREAM,Uri.parse(path) );
startActivity(share);
What am I doing wrong? Why does it nog work for the other Apps?
Few apps will know what to do with an
android.resourceUri. The ones that will mostly will be ones passing it straight toopenInputStream()on aContentResolver. That scheme is very rarely used.If you want to improve compatibility, use a
content://orfile://Uri, pointing at aContentProvideror file on external storage, respectively.