Exception
05-12 15:42:45.791 11043-11043/ E/UncaughtException: java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 631792
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 = 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.