=============== Problem description ====================
The younger brother's project is a jar package containing a page written by dialog. He wants to open the system image library on the page.
If it is in activity, you can
startActivityForResult(new Intent(....),1);
.
How to implement it in dialog.
============= Solution 1 ======================
You can use getcontext (). startactivity (). The same is true, right? You can get the corresponding context object.
============= Solution 2 ======================
I did this in the project.
Customize the dialog, add a callback interface, and set the listening method in the activity to achieve redirection.
Private onoptionclicklistener optionclicklistener = new onoptionclicklistener () {@ overridepublic void onoptionclick (popudialog dialog, int position) {// todo auto-generated method stubif (position = 0) {// photograph intent = new intent (mediastore. action_image_capture); startactivityforresult (intent, requestcode_takephoto);} else if (position = 1) {// select intent = new intent () in the Image Library (); /* enable pictures to set the image type to image */intent. settype ("image/*");/* use intent. action_get_content this action */intent. setaction (intent. action_get_content);/* returns the current screen after obtaining the photo */startactivityforresult (intent, requestcode_selectphoto );}}};
Is it helpful to you?
============= Solution 3 ======================
Upstairs, you can get a returned message through startactivityforresult, and then rewrite it in your fragment class.
Onactivityresult, and then you can get data from the returned bundle. Remember to use
Bitmap BMP = (Bitmap) bundle. getserilizable ("data ");
To obtain the selected image. Of course, this is related to the activity selected for the opened image.
How to open the system image library and use images in the dialog class