Android 通过意图共享映像失败
我正在尝试使用意图共享图像。请找到相同的函数Android 通过意图共享映像失败,android,image,android-intent,Android,Image,Android Intent,我正在尝试使用意图共享图像。请找到相同的函数 if(view.getId()==R.id.sendImage){ Uri imgUri=Uri.parse("android.resource://com.example.watchyalist/mipmap/"+R.mipmap.test); intent=new Intent(Intent.ACTION_SEND); intent.setType("i
if(view.getId()==R.id.sendImage){
Uri imgUri=Uri.parse("android.resource://com.example.watchyalist/mipmap/"+R.mipmap.test);
intent=new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM,imgUri);
intent.putExtra(intent.EXTRA_TEXT,"Please find the image");
chooser=Intent.createChooser(intent,"Choose the app");
startActivity(chooser);
}
这里的测试是我所指的图像,它通过whatsapp共享时发送bin文件。我试过使用ic_启动器,然后它说共享失败。这是我清单文件的快照
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
我无法理解它。我尝试将manifest标签更改为drawable,并相应地将imag保持为drawable,并相应地进行更改,但仍然没有成功。我在project中的mipmap-anydpi-v26文件夹中保存了图像,并尝试更改位置,但没有任何用处。请任何人提供帮助?谢谢
EXTRA\u STREAM
是采用Uri
和内容:
方案<代码>android。资源:不是内容:
。当任何应用程序从你的应用程序接收到你的Uri
时,都不需要知道如何处理它。另外,您的Uri
以半随机数结尾(无论R.mipmap.test
是否适用于此构建)
请将图像复制到文件(例如,在getCacheDir()
中),然后使用FileProvider
和getUriForFile()
获取Uri
以用于额外流