How to open the system image library and use images in the dialog class

Source: Internet
Author: User

=============== 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.