Egor
Egor

Reputation: 40228

Calling Activity.finish() does nothing

I'm having a very strange behavior in my game application. There are two classes - GameActivity and GameManager. GameManager runs all the logic, and GameActivity just hosts a GameManager instance. Now there's a pause menu and an Exit button inside. Clicking it calls finish() on GameManager, which in turn calls the actual finish() method on GameActivity. And the problem is that the call just does nothing. I've put a bunch of log calls in places like onPause(), but neither is getting called. That just seems absolutely weird to me. Will appreciate any kind of help!

Upvotes: 0

Views: 163

Answers (1)

10s
10s

Reputation: 1699

From your comment: Activity.finish() probably does nothing, try passing the actual context of the GameActivity to the game manager.

private Activity gameActivityContext;

//in game activity
onCreate() {
   gameActivityContext = this;
   GameManager mngr = new GameManager(gameActivityContext);
}

//in game manager
....
gameActivityContext.finish();
....

Upvotes: 1

Related Questions