Sometimes you need to jump to the system map to select a map, then use the following code to implement
/**Click to jump to the system gallery and display the selected pictures to the app*/ Public classMainactivityextendsActivity {PrivateImageView IV; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); IV=(ImageView) Findviewbyid (R.ID.IV); } //Click the Jump button Public voidClick (View v) {Intent Intent=NewIntent (); Intent.setaction (Intent.action_pick); Intent.settype ("Image/*"); Startactivityforresult (Intent,2); } @Overrideprotected voidOnactivityresult (intRequestcode,intResultCode, Intent data) { Super. Onactivityresult (Requestcode, ResultCode, data); if(requestcode==2){ if(data!=NULL){//prevent users from not selecting pictures, back when software crashesUri uri =Data.getdata (); Iv.setimageuri (URI); } } }}
This is the result.
Click to jump to the system gallery and display the selected pictures to the app