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 ;}