Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-操作\u从位图发送图像_Android_Android Intent_Bitmap_Bytearray_Bytearrayoutputstream - Fatal编程技术网

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试试这个新代码它对我有用谢谢