Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OnActivityResult is not called on one Android device, but is on another

I have four devices, on one, a Samsung Galaxy 6, I recently noticed that when I attempt to end and send back data from a crop activity the onActivityResult is never called. Instead, it oddly skips the class the onActivityResult is supposed to be on and goes back to the previous activity there. No crashes occur, no nulls that are passed into this code

Bundle extras = new Bundle();
extras.putParcelable(RETURN_DATA_AS_BITMAP, croppedImage);

extras.putIntArray(RETURN_CROP_INFO, cropInfo);
setResult(RESULT_OK,(new Intent()).setAction(ACTION_INLINE_DATA).putExtras(extras));

finish();

Just the onActivityResult is never called.

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        if (resultCode == RESULT_OK) {
            if (requestCode == Constants.INSTANCE.PICK_FROM_FILE ) {
                if (data != null) {
                    try {

Anyone have an idea what this might be? The Samsung and the other phone are both running lollipop.

This is the activation of the custom cropper. The custom cropper code is fairly large though so I am not sure if posting here would make much sense.

private void performCrop(Uri picUri)
{
    // create explicit intent
    Intent intent = new Intent(this, CropImage.class);

    String filePath = picUri.toString();
    intent.putExtra(CropImage.IMAGE_PATH, filePath);
    intent.putExtra(CropImage.SCALE, true);
    intent.putExtra(CropImage.ASPECT_X, 3);
    intent.putExtra(CropImage.ASPECT_Y, 4);
    intent.putExtra("return-data", true);
    intent.putExtra(CropImage.SCALE_UP_IF_NEEDED,true);

    // start activity CropImage with certain request code and listen
    // for result
    startActivityForResult(intent, picCrop);
}
like image 513
Ashley Alvarado Avatar asked Nov 09 '22 06:11

Ashley Alvarado


1 Answers

Just happened to accidentally figure this problem out. I have been getting myself riled up on this problem.

First I attempted to remove the bundle, and pass in the image as a byte array into the intent. It still did not work after doing this.

Then I noticed that if I removed the image from the intent the code managed to reach the onActivityResult on all phones. So I did a workaround by instead of passing the image in the intent I saved it in another class that I accessed in the onActivityResult.

I believe that what I got from this is that the Galaxy 6 phone was the only phone which I possess that created a bitmap larger than can be passed through an intent, as a byte[] or otherwise.

Hope this helps someone later!

like image 145
Ashley Alvarado Avatar answered Nov 14 '22 22:11

Ashley Alvarado