我正在从SQLite检索图像并使用方法CreateChooser共享它,该方法适用于文本,但不适用于图像。
Cursor cursor=sqLiteHelper.getData();
cursor.moveToFirst();
byte[] image= cursor.getBlob(cursor.getColumnIndex("pic"));
Bitmap bmp = BitmapFactory.decodeByteArray(image, 0, image.length);
imageView2.setImageBitmap(bmp);
Toast.makeText(getApplicationContext(),"added",Toast.LENGTH_SHORT).show();
Intent shareintent=new Intent (Intent.ACTION_SEND);
shareintent.setType("image/*");
ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG,100,byteArrayOutputStream);
File file =new File(Environment.getExternalStorageDirectory()+File.separator+"ImageDemo.jpg");
try{
file.createNewFile();
FileOutputStream fileOutputStream=new FileOutputStream(file);
fileOutputStream.write(byteArrayOutputStream.toByteArray());
}catch (IOException e) {
e.printStackTrace();
}
shareintent.putExtra(Intent.EXTRA_TEXT,"abc");
shareintent.putExtra(Intent.EXTRA_STREAM,Uri.parse("content://sdcard/ImageDemo.ipt"));
shareintent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareintent,"Share image to "));
出现警告消息:
W/CursorWindow: Window is full: requested allocation 629733 bytes, free space 207476 bytes, window size 2097152 bytes
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
W/System: A resource failed to call close.
请有人告诉我代码有什么问题吗?我尝试与Gmail和Twitter共享它,但都没有用。谢谢