How to pass an object from one activity to another on Android

后端 未结 30 3977
遇见更好的自我
遇见更好的自我 2020-11-21 04:03

I am trying to work on sending an object of my customer class from one Activity and display it in another Activity.

The code for t

30条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-21 04:53

    • Using global static variables is not good software engineering practice.
    • Converting an object's fields into primitive data types can be a hectic job.
    • Using serializable is OK, but it's not performance-efficient on the Android platform.
    • Parcelable is specifically designed for Android and you should use it. Here is a simple example: Passing custom objects between Android activities

    You can generate Parcelable code for you class using this site.

提交回复
热议问题