views:

20

answers:

1

I’m writing an application (game) where I would like to end the game activity when the user fails the game. My game is loosely based off lunarlander, so I figure it may be easier to ask for help using lunarlander as an example, since a lot of folks are familiar with it.

When the user fails the lunarlander game, I want to automatically end the activity (because my app uses more than one activity). I know that I can use the finish() method inside the activity class, but I can’t use that method inside the surfaceview class or its nested thread. What can I do from inside this class that can be used to end the activity or create a trigger back to the activity class?

Or, is there an entirely different way I should approach this?

Thanks.

+1  A: 

Just a thought but can you call finish on the parent activity.. e.g. getParent().finish();

Or directly access the current context i.e. ((Activity) context).finish();

Dave
It doesn’t look like finish() is exposed under the parent or context....I stand corrected...it isn't exposed without a cast.