Here is my problem... I want to share a png image. I have the image in drawable and assets. When I use the sharingIntent it works but not in the way that I want. The file shared appears with numbers and without extension and some apps send the message "unknow file". What can i do??
this is my code:
Uri uri = Uri.parse("android.resource://com.example.shareimages/" + R.drawable.caja);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "send"));
I tried to use instead of drawable files, the files in assets ( with this "file:///android_asset/...) but it didn't work
Try something like this:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
shareIntent.setType("image/*");
// For a file in shared storage. For data in private storage, use a ContentProvider.
Uri uri = Uri.fromFile(getFileStreamPath(pathToImage));
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(shareIntent)
If you want to share it via the assets folder, you'll have to use a ContentProvider. See this answer on how to do so:
https://stackoverflow.com/a/7177103/1369222
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With