How could you pass data between activities without Intent?

Technology CommunityCategory: AndroidHow could you pass data between activities without Intent?
VietMX Staff asked 4 years ago

The Application object is a way to go, and it is sometimes easier when dealing with the same state across multiple activities (as opposed to having to get/put it everywhere), or objects more complex than primitives and Strings.

You can extend Application, and then set/get whatever you want there and access it from any Activity (in the same application) with getApplication().

Also keep in mind that other approaches you might see, like statics, can be problematic because they can lead to memory leaks. Application helps solve this too.