[java] how to pause a game in mobile to recieve a call?

Started by
3 comments, last by rizwanahmed24 20 years ago
hi Suppose i am playing a game in mobile, a call comes, i can immediately switch to recieve call and after done with the call i am able to resume the game. How this is done, does the game automatically goes in to pause state? and if it goes in to pause state then how? is there any call back to our application incase of call recieve? how the game is resumed? what i think is there is a callback to our application, we store the game state, and to resume we can read the game state , load it and play. bye
Advertisement
If your talking about MIDP then that callback is the MIDlet.pauseApp() method, which you must overload in your MIDlet subclass (the main class).
There are issues on Nokia handsets, which don''t call pauseApp(). For these phones, when the phone call comes in the game''s display will disappear, so you have to choices:
* If you use a Canvas you can intercept this event in the Canvas.hideNotify() method.
* If that isn''t viable you have to constantly poll the isShown() method of the current Displayable, and pause when it''s false.

shmoove
I think this should be posted in the correct forum. Consoles, PDAs, and Cell Phones.
MIDP will call pauseApp. It is then your responsibility to ensure that the game stops playing while the player is on the phone.

Using a normal threading system, you would have a single timer thread. Therefore, pauseApp should probably tell this thread to either pause or stop.

In my game I decided to just stop the timer thread while the app is paused.

Another feature I found useful to implement, is to pause the game briefly (for 500ms or so) after startApp() is called, otherwise the phone seems to get a bit confused (also, it''s a bit unfair on the player to continue the game immediately after they hang up)

Mark
PauseApp is not always implented or called when a phone call is recieved . (Nokia dont)


But the screen is taken over by the call so hideNotify() is always called so implement your save game to rms here and then let the player continue on when they go back to the game!

Brian

This topic is closed to new replies.

Advertisement