Game Development Reference
In-Depth Information
protected void onPause() {
super .onPause();
// Another activity is taking focus (this activity is about to
//be "paused").
}
@Override
protected void onStop() {
super .onStop();
// The activity is no longer visible (it is now "stopped")
}
@Override
protected void onDestroy() {
super .onDestroy();
// The activity is about to be destroyed.
}
Utilizing Handler to Switch Views
When a process is created for your app, its main thread is dedicated to running a message
queue that takes care of managing the top-level objects (activities, broadcast receivers, etc)
and any windows it created. You can create your own threads, and communicate back with
the main app thread through a Handler . This is done by calling the post or sendMessage
methods from your new thread. The given Runnable or Message will then be scheduled in
the Handler's message queue and processed when appropriate.
When posting or sending to a Handler , you can either allow the item to be processed as
soon as the message queue is ready to do so, or specify a delay before it gets processed or
absolute time for it to be processed. The latter two allow you to implement timeouts, ticks,
and other timing-based behavior.
Let's see the snippet:
//Handles view transition
Handler myHandler = new Handler(){
public void handleMessage(Message msg) {
switch (msg.what){
case 0: //progress
//Creates ProgressView.
Search WWH ::




Custom Search