问题
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 how find out if the application in active mode or idle mode?
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/4920220/find-application-mode-is-it-idle-or-not-in-java-me