Call System Camera Album

Source: Internet
Author: User

/** * Jump to System album *  * @param activity *            Active instance * @param requestcode *            request code */public static void Startsystemalbumforre Sult (Activity activity,int requestcode) {Intent Intent = new Intent (Intent.action_pick,media.external_content_uri); Activity.startactivityforresult (Intent, requestcode);}


/** * Call System camera *  * @param activity *            Active instance * @param requestcode *            request code */public static void Startsystemcameraforre Sult (Activity activity,int requestcode) {Intent Intent = new Intent (mediastore.action_image_capture); Activity.startactivityforresult (Intent, requestcode);}


/** * Start System page *  * @param activity *            Current Activity instance * @param requestcode *            Request code * @param data *            photo URI address * @param Widt H *            the width of the cropped image * @param height *            the high */public static void Startphotozoomforresult (Activity activity,int REQUESTC) of the picture after clipping Ode, Uri data, int width, int height) {Intent Intent = new Intent ("Com.android.camera.action.CROP"); Intent.setdataandtype (Data, "image/*");//crop is true to indicate that the view displayed can be clipped Intent.putextra ("crop", "true");//Aspectx aspecty is a ratio of width to height Intent.putextra ("Aspectx", 1); Intent.putextra ("Aspecty", 1);//Outputx,outputy is the width height of the cropped picture Intent.putextra ("Outputx", width); Intent.putextra ("outputy", height), Intent.putextra ("Return-data", true); Activity.startactivityforresult (Intent, Requestcode);}

/** * Get the picture path returned by the system album *  * @param context *            Context Object * @param data *            Intent object carrying data * @return picture local path */public static String Getalbumimgpath (context context, Intent data) {Uri selectedimage = Data.getdata (); if (selectedimage = = null) {retur n NULL;} String[] Filepathcolumns = {MediaStore.Images.Media.DATA}; Cursor C = context.getcontentresolver (). query (selectedimage,filepathcolumns, NULL, NULL, NULL); C.movetofirst (); int ColumnIndex = C.getcolumnindex (Filepathcolumns[0]); String PicturePath = c.getstring (columnindex); C.close (); return picturepath;}

/** * Get the picture returned by the system camera Bitmap Object *  * @param context *            Contextual Object * @param data *            Intent object carrying data * @return Picture Bitmap Object */publ IC Static Bitmap Getcameraimgbitmap (context context, Intent data) {Bundle bundle = Data.getextras (); if (Bundle! = null) {R Eturn (Bitmap) bundle.get ("Data");} return null;}



Call System Camera Album

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.