简体   繁体   English

使用Appcelerator Android检测电源按钮单击

[英]Detect power button click with Appcelerator Android

On Appcelerator Android, is there a way to detect when the user click on the power button to switch off the screen while on the app, and detect when the user switch on the screen while the app is on screen ? 在Appcelerator Android上,是否可以检测到用户在应用程序上单击电源按钮以关闭屏幕时,以及在用户在屏幕上时检测用户何时打开屏幕? I am unable to find an event in the Appcelerator doc, and any module that does that. 我无法在Appcelerator文档以及执行此操作的任何模块中找到事件。

There's no way in Titanium core APIs to detect this specific event. Titanium核心API无法检测到此特定事件。 You can add a callback to the current activity's onPause callback or the current Window's blur event but those will be called/fired in many situations. 您可以将回调添加到当前活动的onPause回调或当前Window的blur事件,但是在许多情况下将调用它们。

You could write a module to detect the keypress: https://stackoverflow.com/a/8668648/4626813 您可以编写一个模块来检测按键: https : //stackoverflow.com/a/8668648/4626813

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

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