4

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?

ॐ Rakesh Kumar
  • 1,318
  • 1
  • 14
  • 24
Rakesh
  • 14,997
  • 13
  • 42
  • 62

1 Answers1

18

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.

ॐ Rakesh Kumar
  • 1,318
  • 1
  • 14
  • 24
  • This answer is absolutely misleading and wrong. If you do call .clear() on your Bundle it will remove the precious data which your Fragment/Activity would use to load back the state of your application when you re-open it after the OS has killed the app in the background. You fix a crash and gain a crash with this approach. – Adam Varhegyi Jul 15 '22 at 12:44
  • In cases where fragments handle their own instance state bundles, the activity will also save all the bundles from all fragments when it goes to save its instance state, double dipping. If the fragments handle their own instance state then you can call clear in the activity no problem. For cases where you have other data you are storing in the activity bundle call clear and then add back what you need to save in the bundle right after. Have a look at https://stackoverflow.com/questions/48453172/transactiontoolargeexception-even-when-file-size-is-super-small. – Eric Aug 24 '22 at 14:30