简体   繁体   English

Adobe AIR移动应用程序的空闲计时器(iOS / Android)

[英]Idle timer for Adobe AIR mobile applications (iOS / Android)

In Adobe AIR there are some useful events such as USER_IDLE and USER_PRESENT to tell if the system is being actively used or is idle after some preset amount of time, BUT they only work for desktop applications (Win / OSX), not for mobile apps (iOS / Android). 在Adobe AIR中,有一些有用的事件,例如USER_IDLE和USER_PRESENT,用于告诉您系统是经过一段时间的使用后还是处于活动状态或空闲状态,但它们仅适用于桌面应用程序(Win / OSX),不适用于移动应用程序( iOS / Android)。

So what are the alternatives? 那么还有哪些选择呢? Hopefully something that doesn't involve manually resetting a timer on each and every touch event thoughout my app. 希望我的应用程序中不需要进行每次触摸事件手动重置计时器的操作。

Thank you! 谢谢!

Why not manually reset a timer? 为什么不手动重置计时器? The USER_IDLE and USER_PRESENT does a very similar job. USER_IDLE和USER_PRESENT的工作非常相似。 Yes, faster, but your manual timer won't affect the performance to a degree where it becomes a bottle-neck. 是的,速度更快,但是您的手动计时器不会在一定程度上影响性能,因为它会成为瓶颈。

It's simple to make too: 制作也很简单:

1) Make a library that receives Stage instance as a parameter. 1)制作一个接收舞台实例作为参数的库。 Add a few listeners to the stage instance: TOUCH_END, TOUCH_BEGIN and other touches you need. 在舞台实例中添加一些侦听器:TOUCH_END,TOUCH_BEGIN和您需要的其他修饰。 If you want add the menu button listener for Android OS. 如果要添加Android OS的菜单按钮侦听器。

2) Make a timer with a long delay (100ms should do). 2)制作一个延时很长的计时器(应该做100毫秒)。 Make a variable - timestamp from last input. 进行一个变量-来自最后一个输入的时间戳。 A variable with time that defines that user is idle (let's say more then 2000ms). 一个带有时间的变量,它定义用户处于空闲状态(比如说2000ms以上)。 And reset the timer on input. 并在输入时重置计时器。 On the tick of the timer check time since last input and write statistics of user activity. 在计时器的滴答声中,检查自上次输入以来的时间,并写入用户活动的统计信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM