Call System camera album, call camera album

Source: Internet
Author: User

Call System camera album, call camera album

/*** Jump to the system album ** @ param activity * Activity instance * @ param requestCode * Request Code */public static void startSystemAlbumForResult (activity, int requestCode) {Intent intent = new Intent (Intent. ACTION_PICK, Media. EXTERNAL_CONTENT_URI); activity. startActivityForResult (intent, requestCode );}


/*** Call the System camera ** @ param activity * Activity instance * @ param requestCode * Request Code */public static void startSystemCameraForResult (activity, int requestCode) {Intent intent = new Intent (MediaStore. ACTION_IMAGE_CAPTURE); activity. startActivityForResult (intent, requestCode );}


/*** Start the system page ** @ param activity * current active instance * @ param requestCode * Request Code * @ param data * photo Uri address * @ param width * width * @ param height * height of the cropped image */public static void startPhotoZoomForResult (Activity activity, int requestCode, Uri data, int width, int height) {Intent intent = new Intent ("com. android. camera. action. CROP "); intent. setDataAndType (data, "image/*"); // If crop is true, the displayed view can be customized. putExtra ("crop", "true"); // aspectX aspectY is a width-high ratio intent. putExtra ("aspectX", 1); intent. putExtra ("aspectY", 1); // outputX, outputY is the width and height intent of the cropped image. putExtra ("outputX", width); intent. putExtra ("outputY", height); intent. putExtra ("return-data", true); activity. startActivityForResult (intent, requestCode );}

/*** Obtain the image path returned by the system album ** @ param context * context object * @ param data * Intent object carrying data * @ return image local path */public static String getAlbumImgPath (Context context, intent data) {Uri selectedImage = data. getData (); if (selectedImage = null) {return null;} String [] filePathColumns = {MediaStore. images. media. DATA}; Cursor c = context. getContentResolver (). query (selectedImage, filePathColumns, null, null); c. moveToFirst (); int columnIndex = c. getColumnIndex (filePathColumns [0]); String picturePath = c. getString (columnIndex); c. close (); return picturePath ;}

/*** Get the Bitmap object returned by the System camera ** @ param context * context object * @ param data * Intent object carrying data * @ return Bitmap object */public static Bitmap getCameraImgBitmap (Context context, intent data) {Bundle bundle = data. getExtras (); if (bundle! = Null) {return (Bitmap) bundle. get ("data") ;}return null ;}



Related Article

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.