×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Eire
    Posts
    182

    Handling Game being Interrupted by Phone calls

    I was reading through what the essential requirements for a mobile game are.

    A mobile game needs to be able to pause and resume if it is interrupted by an event such as a phone call or somebody plugging in a charger.

    Is there a simple MIDP 1 way of handling this? Is there a way of detecting that the phone has been taken over by the phone call or charger screen?

    I would like to keep this simple as possible, is there a way any of you can recommend that wont put me through hell to implement?

    Gratefully Brian

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    USA, FL
    Posts
    148
    hideNotify()
    showNotify()
    resumeCanvas()

    Dima
    Game Artists, LLC

  3. #3
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Eire
    Posts
    182
    How exactly are they used?

    When a phone call is recieved does the phone not call your pauseApp function and then when the call is finshed does the phone not call your startApp function.

    What way are the ShowNotify etc used

    Thanks
    Brian

  4. #4
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    87
    hideNotify() is called whenever your app loses focus on the phone, which is whenever a call is received, when the charging logo appears, etc.
    So you should use hideNotify() to pause your application, I normally do this by setting a boolean (for example, running) to false which will cause the thread to finish and no longer update anything.

    showNotify() is then called whenever your App comes into or back into focus, in which case I usually set 'running' to true and start a new thread.

    DONT USE pauseApp(), the Nokias don't support it, startApp should be used to setup your application at the very start and not do anything after that.

    I hope that helps, I've included an example below.


    Examples:

    public void startApp() // In the Midlet
    {
    if(canvas == null)
    { canvas = new MyCanvas("Hello World");
    game = new Game();
    }
    }

    public void showNofity() // In your App engine (extends Canvas implements Runnable)
    {
    running = true;
    Thread myApp = new Thread(this);
    myApp.start();
    }

    public void run()
    {
    while(running)
    {
    updateStuff();
    repaint();
    serviceRepaints();
    yield();
    }
    }

    public void hideNotify()
    { running = false; // Will break the while loop
    }

  5. #5
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Eire
    Posts
    182
    Ok i've implemented the


    public void hideNotify()
    {
    notPaused = false;
    }


    public void showNofity()
    {
    notPaused = true;
    }

    the structure of the programe is

    run
    {

    while ( running )
    {
    while (notPaused)
    {
    //execute all game code
    }

    }


    So when the MIDlet gets interrupted it sets notPaused = false and the game stops updating!

    Is this enough or should there be something done to threads also?

    Thanks
    Brian

  6. #6
    Registered User
    Join Date
    Nov 2003
    Location
    Helsinki, Finland
    Posts
    15
    By the way...

    "Application should not change focus from screen to another within hideNotify() method.
    (e.g. Display.setCurrent(Displayable d)) In Series 60"

    (Developer Platform 1.0 for Series 60: Usability Guidelines for J2ME™ Games, p 31)

    - J

  7. #7
    Registered User
    Join Date
    Dec 2006
    Posts
    1

    Re: Handling Game being Interrupted by Phone calls

    hi

    i am also facing the same problem i.e regarding phone calls ,i used those methods in my application then als i am not getting , in emulator it is working fine ,but comes to device that shownotify() method it self mot calling

    can u tell me the reson ,if u want i will give the code which i am using

    pla reply me

    thanks and regards

    sunil

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •