The first is the acquisition of photo albums:
Private FinalString Image_type = "image/*";Private Final intImage_code = 0;//the image_code here are arbitrarily defined by themselves.//use intent to invoke the system-provided photo album feature and use Startactivityforresult to get a picture of the user's choiceIntent getalbum=NewIntent (intent.action_get_content); Getalbum.settype (Image_type); Startactivityforresult (Getalbum, IMAGE_CODE) ; //rewrite Onactivityresult to get the information you need@Overrideprotected voidOnactivityresult (intRequestcode,intResultCode, Intent data) { if(ResultCode! = RESULT_OK) {//The RESULT_OK here is a constant system customizationlog.e (TAG,"Activityresult ResultCode Error"); return; } Bitmap BM=NULL; //the data provided by the external program Access ContentProvider can be accessed via the Contentresolver interfaceContentresolver Resolver=Getcontentresolver (); //This is the one you want to use to determine if the activity you're receiving if(Requestcode = =Image_code) { Try{Uri Originaluri= Data.getdata ();//get the URI of the pictureBM= MediaStore.Images.Media.getBitmap (resolver, Originaluri);//appear to bitmap pictureshere begins the second part, gets the path of the picture: string[] proj={MediaStore.Images.Media.DATA}; //It seems to be an interface for Android multimedia database, specifically look at the Android documentcursor Cursor= Managedquery (Originaluri, Proj,NULL,NULL,NULL); //as I understand it, this is the index value of the image that the user chooses. intColumn_index =Cursor.getcolumnindexorthrow (MediaStore.Images.Media.DATA); //move the cursor to the beginning, this is important, careless can easily cause a cross-borderCursor.movetofirst (); //finally get the picture path according to the index valueString Path=cursor.getstring (Column_index); }Catch(IOException e) {log.e (tag,e.tostring ()); } } }
From the online forum it appears that the method of alternate
Android Get Pictures