×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    1

    Close Midlet after inactivity period

    Hi All,

    Iam new to J2ME and have tried searching for this info. Can anyone tell me how to close a Midlet application after a period of inactivity, say 20 minutes?

    A code snippet may be helpful.

    Thanks.

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

    Re: Close Midlet after inactivity period

    Hi ngure76,

    to execute a specified task after a given time, you should use Timer objects.

    For your specific task, you should log into a variable the timestamp of the last user interaction and then, in your TimerTask execution, check if 20 minutes (or any value) have passed since that, and so close the MIDlet.

    Hope it helps,
    Pit

  3. #3
    Regular Contributor
    Join Date
    Apr 2007
    Posts
    220

    Re: Close Midlet after inactivity period

    Hi

    I think you can use the following code-

    public void method()
    {
    int appCloseTime=0;
    while((appCloseTime<1200000)){ //Miliseconds for 20 mins

    try {
    Thread.sleep(1000);
    appCloseTime+=1000;
    } catch(InterruptedException e){
    }


    }
    destroyApp(true);
    notifyDestroyed();
    }


    Regards
    Amit

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: Close Midlet after inactivity period

    Hi,
    You can follow these lines of code,

    1.Note the time on the invocation of application gets invoked,
    2.Keep on checking that that whether the system current time is less than 20 mins
    3.if yes then keep on running the application.else kill the application,

    code---------------------------------------------

    long startTimer;
    startTimer = System.currentTimeMillis();//on invocation
    public void run()
    {
    if(System.currentTimeMillis() - startTimer < 20 mins)
    {
    keep app alive
    }
    else
    {
    destroyApp(true);
    notifyDestroyed();
    }
    }

    i hope this can help you.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. Replies: 0
    Last Post: 2008-09-23, 07:49
  2. j2me Midlet Verification/Validation Problem
    By Nikolaos in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2008-06-16, 16:31
  3. Minimizing and Maximizing a Midlet
    By lekkie in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2007-02-20, 08:15
  4. 技术文档:MIDP 2.0安全机制 与 MIDlet 数字签名
    By wotrust in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 0
    Last Post: 2006-12-30, 07:42
  5. Replies: 3
    Last Post: 2006-10-03, 21:54

Posting Permissions

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