The effect is to click the button, open the System library application, you can choose a picture inside the show out
Set an implicit intent
Get Intent object, come out with new
Call the setaction () method of the Intent Object , set the action, parameter:intent.action_pick
Call the SetType () method of the Intent Object , set the type, parameter:"image/*" can also get video
Call the Startactivityforresult () method to turn on the return value of the
View the system's gallery Source code can know, returned a Intent object, inside the implicit pass data, additional data
overriding method Onactivityresult () method
Gets the Uri pathto the picture, the getData () method of the Intent Object
Image thumbnail Bitmap object, calling the Intent object's Getparcelableextra ("data");
Call the Setimageuri () method of the ImageView object to display the picture directly
//Select Picture Public voidselectimg (View v) {Intent Intent=NewIntent (); Intent.setaction (Intent.action_pick); Intent.settype ("Image/*"); Startactivityforresult (Intent,0); } //Response Callback@Overrideprotected voidOnactivityresult (intRequestcode,intResultCode, Intent data) { if(data!=NULL) {URI Uri=Data.getdata (); Iv_img.setimageuri (URI); } }
[Android] get pictures from gallery