There is no way to directly pass data between activities. The design principle of Android is to use Intent to communicate between different activities and processes, but generally speaking, Intent can only store basic data types and system-based supported such as Uri. Then the data structure defined by the user cannot be directly transmitted with Intent. If you want to pass custom data through Intent, you can enable the data structure to implement the Parcelable interface, so that the data can be placed into the Intent. However, the transmission efficiency of Intent is not very high, especially when passing some big data such as Bitmap. Once I encountered the use of Intent to pass Bitmap with more than 500K, the Java Binder of the Framework layer will be lost, and the result will be unsuccessful.
This can be considered a disadvantage of Android, and there is no good solution. What can be done is to pay attention to designing and try to share basic data types between activities.
Android itself has also suffered greatly from its application. It can be seen that there are many applications with major classes in the source code of more than 3,000 lines. For example, the BrowserActivity in Browser has more than 4,000 lines; the ComposeMessageActivity in Mms also has more than 4,000 lines. etc. The reason why a class is so big is because they are the main page of the program, the core logic of the business, and they also control many other data structures, but cannot be shared with other activities, so they can only do everything in one activity.
In addition, although it is not a good solution, it is acceptable, which is to use a single-key mode for certain data and logic classes, so that each package class (including Activity) can be accessed, such as WorkingMessage, Conversation, Contact and ContactList in the data package in Mms are all single-key.
I hope there will be a better solution in the future SDK.