简体   繁体   中英

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 ? I am unable to find an event in the Appcelerator doc, and any module that does that.

There's no way in Titanium core APIs to detect this specific event. 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.

You could write a module to detect the keypress: https://stackoverflow.com/a/8668648/4626813

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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