How to pass custom object in Bundle?

后端 未结 5 2003
太阳男子
太阳男子 2020-12-13 12:59

I am trying to pass my own custom object into a bundle:

Bundle b = new Bundle();
                STMessage message = (STMessage)a.getAdapter().getItem(positi         


        
5条回答
  •  失恋的感觉
    2020-12-13 13:47

    As Ryan stated. Also if you only want to pass one object on a soft kill consider using onRetainConfigurationInstance and getLastNonConfigurationInstance to pass the serializable object. The entire object tree must be serializable. If you are passing the object via an intent, consider refactoring the object code to a Parceable code later, once the architecture has stabilized. Finally, consider using the fully qualified name of the class when storing the object into the Bundle as in:

    inPWState= (PasswordState) getIntent().getSerializableExtra("jalcomputing.confusetext.PasswordState");
    

    Hope that helps. JAL

提交回复
热议问题