问题
intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpg");
//intent.setType("image/*");
Uri imageUri = Uri.parse("android.resource://com.example.anjuthanm.intenttest/"+R.drawable.test_image);
//Uri imageUri = Uri.parse("android.resource://com.example.anjuthanm.intenttest/drawable/test_image");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
intent.putExtra(Intent.EXTRA_TEXT, "Sent from my app");
chooser = Intent.createChooser(intent, "Send Image");
startActivity(chooser);
When I run the app it opens the chooser dialog box. When I select Whatsapp it toast appears saying file format not supported. When I choose Evernote, the evernote app opens but the image is show as "7985522.null" (Some random number).
I think the image is not getting parsed into a valid uri.
In the tutorial I follow it seems to work for them. Is there anything wrong in the code?
来源:https://stackoverflow.com/questions/40947380/why-uri-parse-does-not-return-valid-image-uri-of-an-image-in-the-drawable-fold