×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Nokia Developer Champion
    Join Date
    Nov 2012
    Location
    Karachi
    Posts
    89

    Failed QA : When receiving an incoming call, the application is not suspended.

    SUMMARY: When receiving an incoming call, the application is not suspended.

    STEPS TO REPRODUCE:
    1. Download the content OTA.
    2. Install and launch the content file.
    3. Receive an incoming call.
    ACTUAL RESULT: The application does not suspend when receiving an incoming call.
    EXPECTED RESULT: The phone call is given user interface focus, as per normal phone operations. The application is paused and the user is able to answer the call. Local and remote users can be heard in the phone call. In applications where immediate user interaction is required (such as games), the content file should go into a pause state.
    AFFECTED DEVICES: Nokia Asha 311 (Firmware: 05.92)
    FREQUENCY REPRODUCED: 100%.

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2012
    Location
    Karachi
    Posts
    89

    Re: Failed QA : When receiving an incoming call, the application is not suspended.

    I am developing a game on ASHA 311,

    ISSUE :When Call comes the game stops automatically and gives call interface, even if you talk for an hour, the game will be stopped. Now when you end the call or when you reject the call after that it takes 3 seconds and then resume. The problem is that if a person wants to use the mobile phone during the call, he would unlock the phone and when the phone will be unlocked the screen focus will come onto the game canvas (just what showNotify() do) so the game starts after a delay of 3 seconds although the person is still on call.


    I want the solution that:

    1- I want to know the status of the phone lock/unlock (any function that returns status)

    2- Any function that tells that the phone is on call so that I can stop the game during that time

    3- Or I want to know how to create a button on game canvas that can run a thread (start a thread)

  3. #3
    Nokia Developer Champion
    Join Date
    Nov 2012
    Location
    Karachi
    Posts
    89

    Failed QA : When receiving an incoming call, the application is not suspended.

    SUMMARY: When receiving an incoming call, the application is not suspended.

    STEPS TO REPRODUCE:
    1. Download the content OTA.
    2. Install and launch the content file.
    3. Receive an incoming call.
    ACTUAL RESULT: The application does not suspend when receiving an incoming call.
    EXPECTED RESULT: The phone call is given user interface focus, as per normal phone operations. The application is paused and the user is able to answer the call. Local and remote users can be heard in the phone call. In applications where immediate user interaction is required (such as games), the content file should go into a pause state.
    AFFECTED DEVICES: Nokia Asha 311 (Firmware: 05.92)
    FREQUENCY REPRODUCED: 100%.

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2012
    Location
    Karachi
    Posts
    89

    Re: Failed QA : When receiving an incoming call, the application is not suspended.

    I am developing a game on ASHA 311,

    ISSUE :When Call comes the game stops automatically and gives call interface, even if you talk for an hour, the game will be stopped. Now when you end the call or when you reject the call after that it takes 3 seconds and then resume. The problem is that if a person wants to use the mobile phone during the call, he would unlock the phone and when the phone will be unlocked the screen focus will come onto the game canvas (just what showNotify() do) so the game starts after a delay of 3 seconds although the person is still on call.


    I want the solution that:

    1- I want to know the status of the phone lock/unlock (any function that returns status)

    2- Any function that tells that the phone is on call so that I can stop the game during that time

    3- Or I want to know how to create a button on game canvas that can run a thread (start a thread)

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,737

    Re: Failed QA : When receiving an incoming call, the application is not suspended.

    If it is a game where time does anything (ranging from a shooter to a logical game where your playing time is measured), the requirement may be something different than what you imagine: when the game losts focus, and gains it back, simply it should not continue the game immediately. The "pause state" here means no midlet lifecycle state but a screen or a screen element asking the user something like "Tap here to resume game". This way it does not matter if the game temporarily/accidentally regains focus.

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Failed QA : When receiving an incoming call, the application is not suspended.

    In order to comply with the certification requirements, you must put your game into a "pause" state when it is interrupted by an incoming call.

    You should detect the incoming call using the hideNotify() event. Set a flag to tell the game to pause. Don't stop any threads, just make sure they pick up the flag you set. Do stop any audio Players!

    You should not attempt to resume the game on a showNotify(). Ideally, don't have any code in the showNotify(). The game should be displaying a "pause" screen ("press 5 to resume", or whatever) until the user manually resumes. Hopefully, all you should need to do is reset the pause flag you set in hideNotify() when the user presses the appropriate key.

    I'm assuming any threads you have (hopefully just one) sits in a loop with a sleep(). While in "pause mode", they should just loop and sleep, and nothing else, checking the pause flag on each loop.

    Graham.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,737

    Re: Failed QA : When receiving an incoming call, the application is not suspended.

    Well, your threads are merged now.

  8. #8
    Nokia Developer Champion
    Join Date
    Nov 2012
    Location
    Karachi
    Posts
    89

    Re: Failed QA : When receiving an incoming call, the application is not suspended.

    Quote Originally Posted by grahamhughes View Post
    In order to comply with the certification requirements, you must put your game into a "pause" state when it is interrupted by an incoming call.

    You should detect the incoming call using the hideNotify() event. Set a flag to tell the game to pause. Don't stop any threads, just make sure they pick up the flag you set. Do stop any audio Players!

    You should not attempt to resume the game on a showNotify(). Ideally, don't have any code in the showNotify(). The game should be displaying a "pause" screen ("press 5 to resume", or whatever) until the user manually resumes. Hopefully, all you should need to do is reset the pause flag you set in hideNotify() when the user presses the appropriate key.

    I'm assuming any threads you have (hopefully just one) sits in a loop with a sleep(). While in "pause mode", they should just loop and sleep, and nothing else, checking the pause flag on each loop.

    Graham.

    How to detect the incoming call,
    Please can someone share the code?

  9. #9
    Registered User
    Join Date
    Feb 2013
    Posts
    6

    Re: Failed QA : When receiving an incoming call, the application is not suspended.

    There is also a problem while intializing a tread globally, how can I pause and resume a thread? I mean there must be a pair of function for this? The game can't be suspended other wise and thats why I need to create a new thread everytime and end the previous one.
    For the screen tap resume thing, can I start/resume a thread by clicking a button? If that so please share the code.

    Thanks

  10. #10
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Failed QA : When receiving an incoming call, the application is not suspended.

    You will need a boolean variable. We're going to access this from two threads, so we make it volatile.

    Code:
    private volatile boolean pauseGame;
    Quote Originally Posted by Shayan Rais View Post
    How to detect the incoming call, Please can someone share the code?
    Assuming a Canvas is displayed, you will receive a hideNotify() event, as I wrote in my previous post.

    Code:
    protected void hideNotify() {
        // we intercept this to detect an incoming call/sms/etc
        pauseGame = true;
    }
    Quote Originally Posted by asjadazeem View Post
    There is also a problem while intializing a tread globally, how can I pause and resume a thread? I mean there must be a pair of function for this?
    You cannot "pause a thread", and I strongly recommend you do not attempt to stop and restart.

    If your thread contains a loop, check the pause flag in the loop.

    Code:
    public void run() {
        while (!exitGame) {
            if (!pauseGame) {
                doGameLogic();
            }
            repaint();
            serviceRepaints();
            makeSureYouSleep();
        }
    }
    
    protected void paint(Graphics g) {
        int width = getWidth();
        int height = getHeight();
        if (pauseGame) {
            // this paints something like "press 5 to resume"
            paintPauseScreen(g, width, height);
        } else {
            paintGameScreen(g, width, height);
        }
    }
    Quote Originally Posted by asjadazeem View Post
    For the screen tap resume thing, can I start/resume a thread by clicking a button? If that so please share the code.
    Easy.

    Code:
    protected void keyPressed(int code) {
        if(pauseGame) {
            if (code == KEY_NUM5) {
                // or some other key
                pauseGame = false;
            }
        } else {
            bufferThisKeyPress(code);
        }
    }
    Quote Originally Posted by asjadazeem View Post
    The game can't be suspended other wise and thats why I need to create a new thread everytime and end the previous one.
    It can be left looping, provided it's doing almost nothing each time around the loop but calling Thread.sleep().

    Why do I suggest you don't stop the thread?

    The obvious thing to do is:

    Code:
    // DON'T DO THIS
    
    private volatile boolean running;
    
    public void run() {
        running = true;
        while (running) {
            // do game stuff
        }
    }
    
    protected void hideNotify() {
        // stop the thread
        running = false;
    }
    
    protected void showNotify() {
        // kick off a new thread to resume the game
        (new Thread(this)).start();
    }
    So, why not?

    You cannot stop a thread. All you can do is leave a message to tell a thread to stop itself, as in the code above with the boolean variable. The thread won't immediately stop... it will only stop next time the loop goes around and checks the variable. On a typical game, on a low end phone, that might be as much as 100ms later.

    What's the problem?

    Some low end devices are not able to run Java apps while handling a call. As soone as the phone rings, the application "goes into the background", which can actually mean that the entire Java VM is frozen and no more bytecode executes until the end of the call. The effect of this is that the events might not happen when you expect.

    Expected: hideNotify() at the start of the call, showNotify() when the call ends.

    Actual: (possibly, depending on device) hideNotif() and showNotify() happen in rapid succession, one then the other, with no delay in between - this can happen if both events are sitting in the event queue when the VM gets "unfrozen".

    Think about what happens in my "don't do this" example, if hideNotify() and showNotify() happen one then other, with no delay in between.

    1. hideNotify() gets called, and sets "running" to false
    2. showNotify() gets called, and starts a new Thread.
    3. the new Thread enters run(), and sets "running" to true
    4. the old Thread eventually loops around, checks "running" and finds it's true - it doesn't fall out of the loop

    We now have two threads running around the game loop and some very odd things happening.

    I have seen this dozens and dozens of times, where game developers have used this technique to stop and restart the game thread. The code works fine on the device they originally tested the code on (probably a Nokia), but causes havoc when you try to get the game working on other devices.

    Allowing the thread to keep running, in a loop where it just "idles" (sleep-loop-sleep-loop-...) is much more reliable across different implementations of MIDP, and never causes any problems in my experience.

    Graham.

  11. #11
    Registered User
    Join Date
    Feb 2013
    Posts
    6

    Re: Failed QA : When receiving an incoming call, the application is not suspended.

    Thank you so much for explaining the issue so well. Sir the last thing I want to ask is that, the game is for Asha Full Touch devices in which I don't have buttonA,B or C, no numpad button as well, Can I use the Green button that is used for call to resume the game? The rest of the things you have said are working now! thanks.

  12. #12
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Failed QA : When receiving an incoming call, the application is not suspended.

    You could...

    Even better, paint a button on the screen (anything rectangular) and use the pointerPressed() event to detect a touch in that rectangle.

Similar Threads

  1. Receiving Events (incoming call, profile changed)
    By klaus3000 in forum Mobile Java General
    Replies: 2
    Last Post: 2009-08-14, 22:24
  2. notification of incoming call receiving, SMS and e-mail
    By silverrocha in forum [Archived] Flash Lite on Nokia Devices
    Replies: 5
    Last Post: 2009-07-04, 14:57
  3. Dialing a call after receiving an incoming call...
    By keerthi.ck06 in forum Symbian
    Replies: 4
    Last Post: 2009-06-23, 16:51
  4. Replies: 3
    Last Post: 2008-09-05, 10:54
  5. Replies: 31
    Last Post: 2008-02-13, 16:45

Posting Permissions

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