Search code examples
androidandroid-intent

Editing Image using Image Uri


I have a image uri and I want to edit that image and obtain the new Image uri. After some searching I found this piece of code and tries to apply.

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

When I try to receive in callbacks I get null in data.

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        System.out.println("REQUEST_CODE: " + requestCode + " " + resultCode + " " + data.getData());
    }

So how to get the new image uri or is there any other way to do this?


Solution

  • ACTION_EDIT is not designed for use with startActivityForResult(), as there is no result. See the documentation, particularly the "Output: nothing" portion.

    What the other app does with the Uri is up to the other app. It might save changes to the original content identified by the Uri that you gave it, or it might not. If it elects to save changes to some new content, there is no means for you to find out where those changes were saved.