Junior — Middle
What tools and mechanisms do you use to implement and manage multithreading in applications?
sobes.tech AI
Answer from AI
In Android, data transfer between screens (Activity, Fragment) is done using:
- Intent with Extras — the most common way to pass data between Activities. You can put primitive types, Serializable, Parcelable objects.
Intent intent = new Intent(CurrentActivity.this, NextActivity.class);
intent.putExtra("key", "value");
startActivity(intent);
-
Bundle — used for passing data between Fragments or saving state.
-
ViewModel and SharedViewModel — for data exchange between fragments within the same Activity via shared ViewModel.
-
Singleton or global classes — for storing data accessible from different parts of the app (not recommended due to state management issues).
-
Architecture components (LiveData, StateFlow) — for reactive data exchange.
-
Third-party libraries (EventBus, RxJava) — for event and data passing between components.
The choice depends on the app architecture and data volume.