What is proper way to exchange data or objects between different Android Activities?
Welcome screen <-> Main Screen <-> Startup routines <-> Processing data <-> Settings
Is it normal/recommended to have more than one activity in Android app? in my opinion, it's somehow strange to have this model of data exchange inside application
We can send the data using the putExtra() method from one activity and get the data from the second activity using the getStringExtra() method.
You can pass the value in 2 ways: Either you make a global Class and set the value in that class and access that class in your 3rd activity. You can use Intent to send your values from 1st activity to 2nd activity.
You need to use Intent Class in order to redirect from one activity class to another activity class. onOptionsItemSelected() Method will be trigged when you click the 'show setting' menu in the action bar.
Is it normal/recommended to have more than one activity in Android app?
Normal? Yes. Recommended? That depends on the app.
in my opinion, it's somehow strange to have this model of data exchange inside application
What do you do with Web apps? Well, you keep your model in a central spot (server) and you pass small bits of context data (URL parameters) in links between major units of UI (pages).
What do you do with desktop apps? Well, you keep your model in a central spot (database) and you pass small bits of context data (e.g., constructor parameters) in links between major units of UI (windows).
What do you do with Android apps? Well, you keep your model in a central spot (database, ContentProvider
, etc.) and you pass small bits of context data (Intent
extras) in links between major units of UI (activities).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With