Apache Cordova - 检测Android Home按钮

phu*_*mai 1 angularjs cordova cordova-plugins ngcordova

我有一个使用angularjs的项目,我使用Cordova构建项目到Android应用程序.在我的项目中,我添加ngCordova并且我想在客户端点击设备中的主页按钮时使用事件.

我引用了http://ngcordova.com/docs/plugins/,但我找不到任何我需要的东西.有人可以帮助我或有任何想法我可以使用吗?

Aki*_*fas 5

主页按钮按钮没有cordova活动.您可以检测应用程序恢复和暂停事件:

 // device APIs are available
//  be sure to add the listener in the device ready event
function onDeviceReady() {
    document.addEventListener("pause", onPause, false);
    document.addEventListener("resume", onResume, false);
}

//runs when the app is on background
function onPause() {
    // Handle the pause event
}

//runs when the app resumes
function onResume() {
    // Handle the resume event
}
Run Code Online (Sandbox Code Playgroud)

更多信息可以在官方的cordova文档中找到