I am building an android application that has an Application object (App) that is ‘controlling’ the flow of the program. When the program starts I present the user with a splash screen while the App class downloads updates, preforms maintenance…etc.
My question is: How do I let the App object change the views – closing the splash screen (I don’t want the user pressing the back button and viewing it again…) then opening the ‘main menu’ view.
I am relatively new to Android, so this setup may not be the best way to structure the Application – applications in the past have struggled when the user has rotated the screen (the activity restarts and re-downloads..etc. the init stuff) This is the solution I have come up with? Correct?
public class App extends Application {
public void onCreate() {
init_work();
// switch views
}
}
This is not the usual approach to developing an app in Android.
A good place to start is:
http://developer.android.com/guide/topics/fundamentals.html
Usually the responsbility of the application is simply to set up global state – IE manage database connections, initiate server communication etc.
The UI flow is generally handled by creating separate Activities. These control the flow by selecting the next activity to run and starting an intent to move to the next stage.
A splash screen could be handled in one of two ways:
Have the first activity create a dialog, which closes itself after a certain time has elapsed.
Create the splash screen as an activity that starts the main activity after a period of time has elapsed, and closes itself using
finish().