Android-操作\u从位图发送图像
我正在尝试将图像发送到其他应用程序,但此代码不起作用。删除文件或显示文件等其他操作有效Android-操作\u从位图发送图像,android,android-intent,bitmap,bytearray,bytearrayoutputstream,Android,Android Intent,Bitmap,Bytearray,Bytearrayoutputstream,我正在尝试将图像发送到其他应用程序,但此代码不起作用。删除文件或显示文件等其他操作有效 ByteArrayOutputStream bos = new ByteArrayOutputStream(); myBitmap.compress(CompressFormat.JPEG, 100, bos); Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("image/jpe
ByteArrayOutputStream bos = new ByteArrayOutputStream();
myBitmap.compress(CompressFormat.JPEG, 100, bos);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, bos.toByteArray());
startActivity(Intent.createChooser(intent, getString(R.string.app_name)));
当我从其他应用程序发送图像时,这些应用程序会崩溃,请尝试以下代码
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("image/jpg");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Pictures/
image.jpg")); // choose your path of the image
startActivity(i);
希望它能帮助你它能工作,但我不想发送电子邮件。只需从非静态文件发送图像即可string@user3657513试试这个新代码它对我有用谢谢