×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    10

    Exclamation Check if phone is being used or not (also not in sleep mode or not)

    Hello,

    I want to check if user is in interaction with the phone.

    My problem is :

    I want to refresh my widget but if it is being used.

    I won't trigger if phone is locked or in sleep mode.

    is this piece of code i look for ? - onactivate attribute of body tag?
    <body onactivate="refresh();">

    Also i've seen onshow method or sth in forum.nokia wiki???

    Do you have any idea?

    Thank you very much.

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Check if phone is being used or not (also not in sleep mode or not)

    Hi onur_ersen,

    if you want to know if user is actively using your WRT Widget, a possible solution could be to capture key/touch events, so that you'll be sure that he's doing something. Then, by checking if the last user interaction was older than a predefined time delta, you could consider the user as inactive, and manage your Widget accordingly.

    Pit

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    10

    Re: Check if phone is being used or not (also not in sleep mode or not)

    Thanx Pit,

    By using the method you've suggested i have to check if any of all keys pressed ?

    For N97 for example check if screen is being touched or yes or no buttons are being pressed... ?

    I thought that auto lock status would be an entry point to check if phone is being used.

    Have you seen anything about checking if keypad lock is active or not ?


  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Check if phone is being used or not (also not in sleep mode or not)

    You can check for key events by defining these listeners:
    Code:
    document.onkeypress;
    document.onkeyup;
    document.onkeydown;
    About the touch events, you can detect them by implementing one or more of these listeners:
    Code:
    document.onclick;
    document.onmousedown;
    document.onmouseup;
    For your specific needs, I think It would be enough to check for onkeypress and onmousedown events. Within these events, just check and store in a variable the current time. Then, by using that variable and a predefined time delta, you should be able to detect if your user is actively using the Widget, or not.

    Pit

  5. #5
    Registered User
    Join Date
    Apr 2009
    Posts
    10

    Re: Check if phone is being used or not (also not in sleep mode or not)

    Thanks again Pit,

    I solved my problem by using the method you've suggested.

    I have one more device specific question

    I compare last refresh time etc and consider to refresh widget or not

    but how about home screen?

    alright i detect if user touched the screen or not in portrait and landscape views
    but in home screen will my onkeypress method be still working ?

    Do you have any idea? Or did you have the chance to test it on real phone?

    Thanks

    ONur.

  6. #6
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Check if phone is being used or not (also not in sleep mode or not)

    Hi ONur,

    touches on a home screen Widget will automatically bring up the Widget full view, so there's no real user interaction with the home screen Widget itself. What you can do is to define a global onresize handler to check when this happens, and behave accordingly.

    Pit

  7. #7
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Check if phone is being used or not (also not in sleep mode or not)

    As a further possible solution to check for user inactivity, you could try to use the UserInactivity System attribute, via the SystemInfo Service API for WRT 1.1 (Entity: Display, Key: UserInactivity).

    Pit

Similar Threads

  1. Replies: 2
    Last Post: 2009-06-13, 05:20
  2. Nokia Gamer (GamR) - concept phone
    By tgm91 in forum General Development Questions
    Replies: 4
    Last Post: 2008-10-01, 21:34
  3. How to set Nokia 12 module to Sleep Mode
    By hugebear688 in forum Nokia M2M
    Replies: 2
    Last Post: 2004-10-31, 09:00
  4. Nokia M12 Sleep mode
    By sagemaster in forum Nokia M2M
    Replies: 4
    Last Post: 2003-11-20, 13:52

Posting Permissions

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