I read much about issues with onActivityResult
, but it seems that none of the described problems fit to mine, like putting a negative requestCode in start
I solved the problem myself now.
After giving up to get onActivityResult
triggering, I decided to 'hack' Androids encapsulating by passing a static reference from MainActivity to CaptureActivity, even if I know that this isn't a good idea.
After the finish()
call, MAGICALLY onActivityResult
gets triggered with Context.RESULT_CANCELLED
... as expected because I don't call setResult
anymore.
Getting onActivityResult
triggered I investigated why it is working now. I found out, that it has something to do with the bitmap, passed to an Intent. If I put a Parcellable
Bitmap into my resultIntent onActivityResult
never gets fired.
So removing following line in the code above will work:
intent.putExtra(Config.SCAN_RESULT_BMP, barcode);
Thats ok for me, because I don't needed the BitMap really in this other Activity. It was more a 'feature' than a need.
If some of you guys want to pass big Data into an Intent
like a Bitmap
, think about storing it somewhere on SD, passing the path in the Intent, while reading this Bitmap
from SD in ParentActivity (How to take a photo by Intent).
As stated here, the Limit of a Parcelable
is 1MB, thus everything bigger passed to an Intent
will cause an internal TransactionTooLargeException
and will silently fail