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

跟風遠走 提交于 2020-01-03 01:23:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!