Android: Edit image intent

2019-03-28 12:33发布

问题:

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:

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

回答1:

Intent editIntent = new Intent(Intent.ACTION_EDIT);
editIntent.setDataAndType(uri, "image/*");
editIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(editIntent, null));


回答2:

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


回答3:

Found a library that can be used for this and is working great. The library can be found here.