开发者

Find application mode, is it idle or not, in Java ME

开发者 https://www.devze.com 2023-02-09 04:17 出处:网络
I want to send stored RMS data using an HTTP connection when the application is in idle mode. So if the user is not doing anything with the application at that time, my thread will invoke and send RM

I want to send stored RMS data using an HTTP connection when the application is in idle mode.

So if the user is not doing anything with the application at that time, my thread will invoke and send RMS data to server.

For this requirement, how do I h开发者_StackOverflowow find out if the application in active mode or idle mode?


You could wait for the backlight to go off, if that's enough of an indication of whether the application is active.

Implement the SystemListener2 interface, there's a method backlightStateChange() that will be invoked after the object is registered with Application.addSystemListener


I do not see any smarter solution than using Displayable.setCommandListener(CommandListener l).

The command listener should use Timer. When a certain timeout (let's say 60 seconds) is expired, the timer task should run and trigger sending your data. I think that if you have access to the midlet's code, this solution is not so bad.

0

精彩评论

暂无评论...
验证码 换一张
取 消