samedi 11 avril 2015

Get image path android

I wanto to load an image into an ImageView on android. Now, i know that if the image is too large, i have to scale it so that it doesn't take too much memory.


I want to do that doint what it says here: http://ift.tt/IVCkbR


Now, the way i get the image is via it's URI like this:



Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"text"),1);


protected void onActivityResult(int reqCode, int resCode, Intent data){
super.onActivityResult(reqCode, resCode, data);

if (reqCode == 1 && resCode == RESULT_OK && data != null) {
Uri selectedImage = data.getData();
}
}


And if i want to use some decode*() method, i cannot do that with the URI. So my frist choice was to use:



decodeFile(imageUri.getPath(),options);


But when i do that, the path i get from the gallery are something like: /documents/image:9023


How should i do this? I just need to open the gallery and get and image from displaying and also be able to save it as a bitmap so i can edit it.


Aucun commentaire:

Enregistrer un commentaire