Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Edit image intent

I found a lot of questions for how to crop an image. But, is there a way to start the edit image activity through an intent. I tried with com.android.camera.action.EDIT but it's not working. What I want to do is when I click on a button, start the activity for editing the image, like the one on the picture below:

enter image description here

It's like when I open an image from the gallery and click Edit from the menu.

like image 571
nikmin Avatar asked Mar 29 '13 07:03

nikmin


Video Answer


2 Answers

Intent editIntent = new Intent(Intent.ACTION_EDIT);
editIntent.setDataAndType(uri, "image/*");
editIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(editIntent, null));
like image 200
Darren Hinderer Avatar answered Oct 18 '22 22:10

Darren Hinderer


        Intent intent = new Intent("com.android.camera.action.CROP");
        intent.setDataAndType(yourimageuri, "image/*");
        intent.putExtra("crop", "true");
        intent.putExtra("aspectX", 1);
        intent.putExtra("aspectY", 1);
        intent.putExtra("outputX", 640);
        intent.putExtra("outputY", 640);
        intent.putExtra("scale", true);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outPath);
        intent.putExtra("return-data", false);
        intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
        intent.putExtra("noFaceDetection", true);
        startActivityForResult(intent, CAMERA_CROP_RESULT);
like image 2
Jiang Qi Avatar answered Oct 18 '22 20:10

Jiang Qi