我已经包含了“通过myApp共享”选项。我在接收activity类中插入了以下代码。
// Get the intent that started this activity
Intent intent = getIntent();
Uri data = intent.getData();
// Figure out what to do based on the intent type
if (intent.getType().indexOf("image/") != -1) {
// Handle intents with image data ...
}
检索位图图像的下一步是什么。
发布于 2013-12-26 18:05:53
因为您已经获得了Uri。现在,您必须在getBitmap()
中传递该Uri以获取位图并使用该位图。
Uri imageUri = intent.getData();
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(),imageUri);
Imageview my_img_view = (Imageview ) findViewById (R.id.my_img_view);
my_img_view.setImageBitmap(bitmap);
发布于 2013-12-26 18:00:15
为了从uri获取位图,
Bitmap mBitmap = Media.getBitmap(this.getContentResolver(), uri);
希望这对你有帮助。
发布于 2017-03-03 13:09:55
Retrive bitmap from uri.....
public static Bitmap decodeUriToBitmap(Context mContext, Uri sendUri) {
Bitmap getBitmap = null;
try {
InputStream image_stream;
try {
image_stream = mContext.getContentResolver().openInputStream(sendUri);
getBitmap = BitmapFactory.decodeStream(image_stream);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return getBitmap;
}
https://stackoverflow.com/questions/20782713
复制相似问题