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

Detect power button click with Appcelerator Android

在 Appcelerator Android 上,有没有办法检测用户何时在应用程序上单击电源按钮关闭屏幕,以及检测用户何时在应用程序运行时打开屏幕在屏幕上 ? 我无法在 Appcelerator 文档中找到事件,也找不到任何相关模块。

Titanium 核心 API 无法检测到此特定事件。您可以向当前 activity 的 onPause callback or the current Window's blur 事件添加回调,但在许多情况下这些事件将是 called/fired。

您可以编写一个模块来检测按键: