Exception thrown launching activities in ProcessRecord{3c67ecf8080:com.example/u0a171} android.os.TransactionTooLargeException: data parcel size 572488 bytes
Passing data
Intent intent = new Intent(activity, SearchListActivity.class);
intent.putExtra(HRConstants.SEARCHLIST, searchResponse);
startActivity(intent);
Getting Data
Intent intent = getIntent();
searchResponse = intent.getParcelableExtra(HRConstants.SEARCHLIST);
searchLists = searchResponse.getSearchResults();
My minSdkVersion
is 15 and targetSdkVersion
is 26.
The response contained 1736 items followed by an exception. It works fine with fewer items.
This is because intents in Android can carry no more than 1MB of data. A workaround would be puting "searchResult" inside a public static object
Intent intent=new Intent(activity,SearchListActivity.class);
//intent.putExtra(HRConstants.SEARCHLIST, searchResponse);
YourActivity.SearchResponse = searchResponse;
startActivity(intent);
In the SearchListActivity, instead of doing
getIntent.getExtras();
you can access your object now saved into
List<Search> list = YourActivity.SeachResponse;
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With