TransactionTooLargeException in Nougat

Your are passing too much data to your Fragment in setArguments(). Your Fragment will work, but when it tries to save its instance state it overflows the transaction buffer. This throws a RuntimeException if you target Android 7.0 (API 24 or higher). To preserve backwards compatibility and not break existing apps, the new behaviour is only used if you target API 24 or higher. If you target API < 24, the transaction buffer overflow exception is caught and silently ignored. This means that your data will not be persistently saved, which you may (or may not) notice.

Your code is broken. You should not pass large amounts of data to the Fragment in setArguments(). You can keep your data in your Activity. When the Fragment wants to access the data, it can always so something like this:

// Get the owning Activity
MyActivity activity = (MyActivity)getActivity();
// Get the data from the Activity
List<Data> data = activity.getData();

In your Activity, write a getData() method that returns a reference to whatever data the Fragment needs.

In this way, the data is held in the Activity and the Fragment can get access to it whenever it needs to.


Android 7.0 (Nogat) includes a variety of system and API behaviour changes. Regarding TransactionTooLarge Exception :

In Android 7.0, many platform APIs have now started checking for large payloads being sent across Binder transactions, and the system now rethrows TransactionTooLargeExceptions as RuntimeExceptions, instead of silently logging or suppressing them. One common example is storing too much data in Activity.onSaveInstanceState(), which causes ActivityThread.StopInfo to throw a RuntimeException when your app targets Android 7.0.

Possible Solutions : 1. Save required object in global cache and pass only the key to DetailsActivity to retrieve the object.


Regarding the Doc This Exception throw when value are too large to fit in the transaction buffer. And might be a complicated issue, for a big project, where you can invokes several actions with sending Intent in difference places.

Your example demonstrate this issue, even with single object. And you should change your transferring behavior at all. For ex. by trimming object, to contain only important info. Intent Extra Data should have only lightweight info!


In you example you have field, which might produce this issue. Probably you are using Base64 Encoded image. Exception with message text, specific only for Android 23. Check the doc.

public String getImage() {
    return image;
}

public void setImage(String image) {
    this.image = image;
}