The application starts and works well when you rotate the screen. But when the screen is minimized, it gives an error. This happens on Nougat. In older versions of the error does not occur when the screen is minimized.

07-12 09:25:04.245 26750-26750/com.example.ewrei.tanksapi E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 1585564) 07-12 09:25:04.245 26750-26750/com.example.ewrei.tanksapi D/AndroidRuntime: Shutting down VM 07-12 09:25:04.253 26750-26750/com.example.ewrei.tanksapi E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.ewrei.tanksapi, PID: 26750 java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1585564 bytes at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3781) 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:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: android.os.TransactionTooLargeException: data parcel size 1585564 bytes at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(Binder.java:615) at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3636) at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3773) 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:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

Code itself

  public class Fragment_sravnenie_print extends Fragment { private Player player; private Player playerSravnenie; ................................... public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sravnenie_print, container, false); Bundle bundle = getArguments(); if (bundle != null) { player = bundle.getParcelable("player"); playerSravnenie = bundle.getParcelable("player_sravnenie"); } ................................. //Получение ресурсов и заполнение RecyclerView } } 

I tried to do it myself as well as from the documentation Processing changes in the execution mode . Well, nothing happened. The error has not changed. This error occurs in all fragments where I use Bundle . There is a fragment where I receive the data through a class inherited from Application . It quietly folds and does not give any errors.

Update: I try this

  public class Fragment_sravnenie_print extends Fragment { private Player player; private Player playerSravnenie; ................................... private DataFragment dataFragment; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sravnenie_print, container, false); FragmentManager fm = getFragmentManager(); dataFragment = (DataFragment) fm.findFragmentByTag("data"); if (dataFragment == null) { Bundle bundle = getArguments(); if (bundle != null) { player = bundle.getParcelable("player"); playerSravnenie = bundle.getParcelable("player_sravnenie"); } // add the fragment dataFragment = new DataFragment(); fm.beginTransaction().add(dataFragment, "data").commit(); // load the data from the web dataFragment.setPlayer(player); dataFragment.setPlayer_sravnenie(playerSravnenie); } else { player = dataFragment.getPlayer(); playerSravnenie = dataFragment.getPlayer_sravnenie(); } ................................. //Получение ресурсов и заполнение RecyclerView } @Override public void onDestroy() { super.onDestroy(); // store the data in the fragment Log.e("TEST", "Data_Destroy"); dataFragment.setPlayer(player); dataFragment.setPlayer_sravnenie(playerSravnenie); } } 

And a fragment

 public class DataFragment extends Fragment{ private Player player; private Player player_sravnenie; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // retain this fragment setRetainInstance(true); } public Player getPlayer_sravnenie() { return player_sravnenie; } public void setPlayer_sravnenie(Player player_sravnenie) { this.player_sravnenie = player_sravnenie; } public Player getPlayer() { return player; } public void setPlayer(Player player) { this.player = player; } 

}

    2 answers 2

    You transfer objects larger than 1 megabyte in the bundle

    Try to save big data to a local database, or just to a file, and do not forget about caching :)

    • As I understand you, I can transfer my data to json, then save it to a file or a local database. After that, in the Bundle, I pass the file name or the name of the local database table. And in the fragment I already get this data - Vitaly Robinovsky
    • Yes, you can do that. Only if you want to save the database, transfer to json is not necessary. What to choose - base or json - decide on the basis of the problem. If, for example, you make various samples according to the data, or delete / insert new data as you work, then it is better to use the base. If you just downloaded and use a piece of data from the server - you can limit the file - mrBatonec
    • Thank you you helped me a lot, I will do) - Vitaly Robinovsky

    Add setRetainInstance(true); in the public void onCreate(Bundle savedInstanceState) fragment, and in the main Activity add saving data to the Fragment in the onDestroy method of your onDestroy and loading it into onCreate .

    Saving objects with state preservation in a fragment during configuration changes in runtime mode:

    1. Extend the Fragment class and declare references to stateless objects.
    2. Call setRetainInstance(boolean) when the fragment is created.
    3. Add a fragment to the operation.
    4. Use the FragmentManager to extract a fragment when the operation is restarted.

    You have a situation described here.

    • It did not work, and I save the data in the fragment. As I receive the data from the server in a fragment and I transfer already in this fragment. I updated the question as I did. Well, the error remains the same - Vitaly Robinovskiy