简体   繁体   English

无法将我的应用程序中的图像作为隐式意图发送到外部应用程序

[英]Can't send image in my application to external app as implicit intent

I am new to android i have read mant aricles on this from stackoverflow and other resources but i tried my best to get result At time of sending i select gmail to send my image but its showing empty file cant be attached i tried with different images in my package but i get the same response Here is my code which i tried 我是新来的android我已经从stackoverflow和其他资源上阅读了这个问题,但我尽力得到结果在发送时我选择gmail发送我的图像但它显示空文件不能附加我试过不同的图像在我的包但我得到相同的回复这是我尝试的代码

    Intent intent;     
   Uri imageUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE +
                        "://" + getResources().getResourcePackageName(R.drawable.cursor)
                        + '/' + getResources().getResourceTypeName(R.drawable.cursor) + '/' +
                        getResources().getResourceEntryName(R.drawable.cursor) );
                intent=new Intent(Intent.ACTION_SEND);
                intent.setType("image/jpeg");
                intent.putExtra(Intent.EXTRA_STREAM, imageUri);
                chooser=Intent.createChooser(intent, "Select app to send");
                startActivity(chooser);

Hope this helps: 希望这可以帮助:

BitmapFactory.Options options = new BitmapFactory.Options(); 
options.outMimeType = "image/jpeg";

Bitmap bitmap= BitmapFactory.decodeResource(getResources(),
        R.mipmap.ic_launcher, options);

String path = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "Image Description", null);
Uri uri = Uri.parse(path);

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Share Image"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM