[android-developers] onRestart() method not called on restart

2010-04-15 Thread nickon
Hey everyone,

I'm writing a Tetris application on Android for my bachelor thesis at
the University of Hasselt.
Currently I have a working Tetris base game, but it just keeps on
ticking when the activity gets in the background.

I'm trying to fix this by overwriting the onStop() and onRestart()
methods.
Here is what I do:

@Override
public void onStop(){
super.onStop();

// Pause the game along with the activity
ATetrisGame.getInstance().setMode(GameMode.PAUSE);
}

@Override
public void onRestart(){
super.onRestart();
ATetrisGame game = ATetrisGame.getInstance();

// We are restoring a previously PAUSED game
if(game.mode() == GameMode.PAUSE){
ATetrisGame.getInstance().setMode(GameMode.ACTIVE);
}
}

So when I press my home button on my device I will go to my home
screen and onStop() is called. Because the gamemode is now PAUSE,
the game wil not tick anymore.
But now, when I longpress my home button and select my tetris activity
again, the activity pops up, but it isn't ticking!
This is because the onRestart() is never called when I return to play
my application!

What is the reason that this method is never called? Am I
understanding the activity lifecycle wrong?

Thanx in advance guys!
Greetings,
Nick

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.


Re: [android-developers] onRestart() method not called on restart

2010-04-15 Thread ~ TreKing
On Thu, Apr 15, 2010 at 11:05 AM, nickon nickvanbae...@gmail.com wrote:

 What is the reason that this method is never called? Am I understanding the
 activity lifecycle wrong?


Not sure, but I've never used onStop or onRestart. I would use onPause and
onResume.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.