Selecting images from the gallery is a very common feature in our development, such as uploading avatars and uploading albums. Android4.4 Previous version Open the gallery Select picture can be this:
Intent Intent = new Intent (intent.action_get_content, null); Intent.settype ("image/*"); Activity.startactivityforresult (Intent, Start_album_code);
Or:
Intent Intent = new Intent (Intent.action_pick, null); Intent.setdataandtype (MediaStore.Images.Media.EXTERNAL_CONTENT _uri, "image/*"); Activity.startactivityforresult (Intent, Start_album_code);
Then we rewrite Onactivityresult (), and in the returned data we can get the path of the image (how to get path can be searched online).
But in the Android4.4 test but there is a problem, get the correct path, get the path is this:/document/image%3a29817, and our normal path:/mnt/sdcard/dcim/100media/ Imag0021.jpg, not the same.
The method that works on Android4.4 should be this way (also compatible with the previous version of 4.4):
Intent Intent = new Intent (Intent.action_pick,android.provider.mediastore.images.media.external_content_uri); Intent.setdataandtype (MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); Activity.startactivityforresult ( Intent, Start_album_code);
This will enable you to obtain the correct path.
Ps:
Another solution (feeling written is cumbersome, not verified, for reference only): http://blog.csdn.net/tempersitu/article/details/20557383
QQ Exchange Group: 6399844
Android4.4 the path returned from the gallery select picture is not the correct workaround