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.
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.
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
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
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,