I am sending an request for result from onActivityresult () but not receiving it inside the same activity.

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Uri myUri = Uri.parse("");
    if(resultCode==RESULT_OK  && requestCode==PHOTO){
        List<String> mSelected = Matisse.obtainPathResult(data);
        Uri original = Uri.fromFile(new File(mSelected.get(0)));

        UCrop.of(original, myUri)
                .withAspectRatio(16, 9).start(Settings.this);
    }

    if(resultCode==RESULT_OK && requestCode==UCrop.REQUEST_CROP){
        Log.e("Got", "here");
        Uri resultData = UCrop.getOutput(data);
        File file = new File (resultData.getPath ());
        File Compressed=null;
        try {
            Compressed = new ImageZipper(getApplicationContext()).setQuality (75).setMaxWidth (640).setMaxHeight (480).setCompressFormat (Bitmap.CompressFormat.PNG).compressToFile (file);
        } catch (IOException e) {
            Toast.makeText (getApplicationContext(), "Error 407: " + e.getMessage (), Toast.LENGTH_SHORT).show ();
        }
        Uri UploadUri = Uri.fromFile (Compressed);
        EditProfile.ImageUri = UploadUri;
        userProfile.setImageURI(UploadUri);
        EditProfile.isImageUpdated = true;
    }
}`

I added this in requestCrop result but it is not showing in LogCat. As I crop is done successfullyLog.e("Got", "here");

1 Answers

0
Meet Patel On

To send data for Activity Restult

Intent intent = new Intent(context, Activity.class);
startActivityForResult(intent, ACTIVITY_RESULT_CODE);

You will Get Sent Data On Activity Result

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
     if (data != null) {
                switch (requestCode) {
                    case ACTIVITY_RESULT_CODE:
                    // You will get your Sent data here...
                    break;
                }
     }