In short, I am trying to select an image from the phone’s gallery to display it as a bitmap that needs to be reproduced (get the average RGB value) in another activity.
Firstly, I came across several topics regarding the URI for Bitmap conversion. Many of them have suggestions such as (from: Extract bitmap from 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);
The bitmap line is an important line. Whenever I run my Android application on my simulator, the application crashes (the debugger in Eclipse confirms what happens in the URI → Bitmap conversion string), and if I put the conversion in different actions (it is included), then it’s all equally will fail in the conversion string Uri → Bitmap.
I am not sure why this is so. I tried to make my intentions both "EXTERNAL_CONTENT_URI" and "INTERNAL_CONTENT_URI" in the original intention, and any choice does not matter. I will continue to search for potential solutions to my problem, but now I have a short time, and I feel that it would be useful if I had any advice from external sources.
Does anyone know why it always crashes on this line, or if there are any possible solutions to my problem? Thanks.
android image bitmap
Nodetails
source share