Android Intent file format not supported

I am trying to transfer an image from my folder. It worked before, but now, for some reason, when I try to share, I will choose a person to share it with, and it will give me a message that says: "the file format is not supported." For some reason I cannot share it with Whatsapp, but I can share it with another application like snapchat. Therefore, I know that he is getting the right image.

Here is my sharing code:

Uri imageUri;
imageUri = Uri.parse("android.resource://" + getPackageName() + "/drawable/" + "image" + String.valueOf(mViewPager.getCurrentItem() + 1));
//imageUri = Uri.parse("android.resource://" + getPackageName() + R.drawable.image1);
Log.d("Sharing", "android.resource://" + getPackageName() + "/drawable/" + "image" + String.valueOf(mViewPager.getCurrentItem() + 1));
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
//sharingIntent.putExtra(Intent.EXTRA_TEXT, "Ha Ha! Check out this picure I got with todays date! Download the app: http://www.google.com");
sharingIntent.setType("image/jpg");
sharingIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(sharingIntent, "Share via"));

Here is the error I got from the logs, but I am not using ArrayList for sharing.

W/Bundle: Key android.intent.extra.STREAM expected ArrayList but value was a android.net.Uri$StringUri.  The default value <null> was returned.

And what gives Log.d:

D/Sharing: android.resource://com.trommelen.okke.scheurkalender/drawable/image155
+4
source share
1 answer

, android.permission.WRITE_EXTERNAL_STORAGE

Bitmap imgBitmap=BitmapFactory.decodeResources(getResources(),R.drawable.image1);
String imgBitmapPath=Images.Media.insertImage(getContentResolver(),imgBitmap,"title",null);
Uri imgBitmapUri=Uri.parse(imgBitmapPath);

imgBitmapUri .

+1

All Articles