[Javame] Incoming call)

Source: Internet
Author: User

For example, if your game is in progress, but suddenly a phone call occurs, can you ensure that your game will not crash?
To solve the call problem, the only thing that needs to be done is to reload the canvas enoworkflow () method of canvas.

Just like this:

Boolean Gameispaused;
 
Protected   Void Showpolicy () {Gameispaused= False;
}
 
Protected   Void Hidenotify () {
Gameispaused= True;
}
 
Private   Void Themaingameloop () {
While (Gameisrunning) {< br> If ( ! gameispaused) {< br> /// process events and update the screen
}
}
}

However, as mentioned in the following post, the problem with the Nokia 7650 model cannot be overcome. When you close the game while answering the phone, you cannot start the game after the phone is called, unless you restart your phone.

Reference posts:
Http://forum.java.sun.com/thread.jspa? Forumid = 76 & threadid = 581789.
Http://forum.java.sun.com/thread.jspa? Forumid = 76 & threadid = 376907.

reference:
In fact, when the MIDlet is hidden, it is always paused. This is especially important in game applications, because players may lose the game if the game is not immediately suspended when the game
is hidden.
you can use the displayable-like method isshown (), canvas-like, or customitem-like method hidenovel () to pause the MIDlet.
after the canvas object leaves the display, the hidenotify () method is called immediately. Create
an automatic pause mechanism in the hidenotify () method to pause threads, disable timers, and save important values. See the following Code example:
protected void hidenoworkflow ()
{< br> // when the pause is executed
remainingtime = endtime-system. currenttimemillis ();
mythread. stop ();
autopaused = true;
repaint ();
// include a pause test in paint () method To check if paused
// paint a pause message on screen if autopaused true
}< br> protected void paint (Graphics g)
{< br> // paint game screen Here
If (autopaused = true) {
// paint pause message
}< BR >}< br> after the pause, the operation continues, therefore, the continue option must be displayed to the user.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.