On Android N whenever I pass some binary or large data in bundle I get a TransactionTooLargeException, however it runs without issues on android M and below.
How can I solve this?
On Android N whenever I pass some binary or large data in bundle I get a TransactionTooLargeException, however it runs without issues on android M and below.
How can I solve this?
There has been a behavior change in Android N
Quoting the docs:
Many platform APIs have now started checking for large payloads being sent across
Bindertransactions, and the system now rethrowsTransactionTooLargeExceptionsasRuntimeExceptions, instead of silently logging or suppressing them. One common example is storing too much data inActivity.onSaveInstanceState(), which causesActivityThread.StopInfoto throw aRuntimeExceptionwhen your app targetsAndroid 7.0.
Note: Apps targeting M or below won't throw the exception, they will just silently log or suppress them
Rethink why you need so much data in bundle in the first place.
If it is binary data or a bitmap, it is best to store it in a file and pass the path in the bundle.
If you are passing too many objects
You can use libraries like Otto,EventBus to avoid it.
Just pass the necessary info required for constructing the Object once again.
Create a singleton class and set the data there and access it in another Activity or Fragment from there.