问题
I am using Bundle
to transfer data between activities and fragments. When I navigate from one fragment to new fragment, Without transferring data or using Bundle
to get the data, Application is crashing with below error.
> > 10-09 11:36:09.100 467-467/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 558780) 10-09 11:36:09.101 467-467/?
> D/AndroidRuntime: Shutting down VM 10-09 11:36:09.101 467-467/?
> E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxxx.xxxxmobileapp.debug, PID: 467 java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 558780 bytes at android.app.ActivityThread$StopInfo.run(ActivityThread.java:4156) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6682) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) Caused by: android.os.TransactionTooLargeException: data parcel size 558780 bytes at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(Binder.java:628) at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:4149) at android.app.ActivityThread$StopInfo.run(ActivityThread.java:4148) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6682) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Can we use the bridge or any third party tool to address the issue? How to address this issue?
回答1:
You must be passing a long string with Bundle
like this and you have to clear the Bundle
where you are receiving data. You can use whatever way thinks good.
1.Method:
Bundle bundle = new Bundle();
bundle.putString("This is just for testing purpose", "Developer program");
To clear bundle object on Fragment
@Override
public void onViewCreated(View view, Bundle savedInstanceState)
{
String recStr= bundle.get("This is just for testing purpose");
bundle.clear();
}
2.Method
@Override
protected void onSaveInstanceState(Bundle oldInstanceState)
{
super.onSaveInstanceState(oldInstanceState);
oldInstanceState.clear();
}
It'll help you.
来源:https://stackoverflow.com/questions/52716060/java-lang-runtimeexception-android-os-transactiontoolargeexception-data-parcel