I transfer object of the class (I implement Parcelable) from one activit to another through Intent. From the second activit to the fragment located on this activit (via the Bundle). In the logs:

E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 2557032) 

The object is not large, 4 variables of type String. What could be an alternative to transferring data between activations?

UPDATE: In the first activation you have to store about 1000 objects of its class. When you rotate the screen, all objects save the trace. in the following way:

  @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelableArrayList(KEY_RESULT_LIST, (ArrayList<? extends Parcelable>) resultList); } 

The approach itself is nioc. How much will singleton be justified in this case?

    1 answer 1

    If only String variables, and indeed if the variables of the object are primitive, then you can inherit the Serializable interface.

     public class MyClass inplements Serializable { } 

    In the intent is cast like this:

     MyClass objectToSend = new MyClass(); Intent intent = new Intent(); intent.putSerializable ("data", objectToSend); 

    In the activation we get this:

     MyClass obj = (MyClass) getIntent.getSerializableExtra("data"); 

    Also in Serializable you can throw an ArrayList

    • Serializable, as far as I know, is slower than Parcelable. Although when transferring one object, this difference will probably not be noticeable. - dmk