Archived

This topic is now archived and is closed to further replies.

rizwanahmed24

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

Recommended Posts

rizwanahmed24    122
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

Share this post


Link to post
Share on other sites
shmoove    821
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

Share this post


Link to post
Share on other sites
markr    1692
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

Share this post


Link to post
Share on other sites
Woody FX    169
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

Share this post


Link to post
Share on other sites