Android studio 如何将android中的图像从我的应用发送到其他应用?

Android studio 如何将android中的图像从我的应用发送到其他应用?,android-studio,android-implicit-intent,Android Studio,Android Implicit Intent,我想使用ACTION_send将存储在drawable文件夹中的图像发送到其他应用程序,我的代码如下所示: if(view.getId()==R.id.sendimage) { Uri imageUri=Uri.parse("android.resource://"+getPackageName()+"/drawable"+R.drawable.screen)‌​; intent=new Intent(Intent.ACTION_SEND); intent.setType("i

我想使用ACTION_send将存储在drawable文件夹中的图像发送到其他应用程序,我的代码如下所示:

if(view.getId()==R.id.sendimage) { 
   Uri imageUri=Uri.parse("android.resource://"+getPackageName()+"/drawable"+R.drawable.screen)‌​; 
    intent=new Intent(Intent.ACTION_SEND); intent.setType("image/*"); 
    intent.putExtra(Intent.EXTRA_STREAM,imageUri); 
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
    chooser=intent.createChooser(intent,"Send Image Via");
    startActivity(chooser);
 } 
但当我尝试使用应用程序中的按钮将邮件发送到Gmail时,会出现一条toast消息“无法附加空文件”,其他应用程序在发送邮件时也会出现类似消息,一些应用程序甚至崩溃。
所以你能帮我找出错误吗???

发布代码不是代码的图像。如果(view.getId()==R.id.sendimage){Uri imageUri=Uri.parse(“android.resource://“+getPackageName()+”/drawable“+R.drawable.screen”);intent=newintent(intent.ACTION\u SEND);intent.setType(“image/*”);intent.putExtra(intent.EXTRA_流,imageUri);intent.addFlags(intent.FLAG_授予_读取_URI_权限);chooser=intent.createChooser(intent,“通过发送图像”);startActivity(chooser);}