Angularjs Apache Cordova-检测Android主页按钮按下

Angularjs Apache Cordova-检测Android主页按钮按下,angularjs,cordova,cordova-plugins,ngcordova,Angularjs,Cordova,Cordova Plugins,Ngcordova,我有一个使用angularjs的项目,我使用Cordova来构建android应用程序的项目。在我的项目中,我添加了ngCordova,我想在客户端单击设备中的主页按钮时使用事件 我读了,但没有找到我需要的东西。有人能帮我吗?有人知道我能用什么吗?科尔多瓦没有Home按钮按下的活动。您可以检测应用程序恢复和暂停事件: // device APIs are available // be sure to add the listener in the device ready event fu

我有一个使用angularjs的项目,我使用Cordova来构建android应用程序的项目。在我的项目中,我添加了
ngCordova
,我想在客户端单击设备中的主页按钮时使用事件


我读了,但没有找到我需要的东西。有人能帮我吗?有人知道我能用什么吗?

科尔多瓦没有Home按钮按下的活动。您可以检测应用程序恢复和暂停事件:

 // 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
}

有关更多信息,请访问

在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
}

据我所知,在

上可以找到更多信息,没有明确的事件,但您可以使用暂停事件。每次应用程序进入后台时(按home按钮时就是这种情况),它都被称为。查看。我知道,但当我收到消息时,暂停事件处于活动状态,我不希望出现这种情况。据我所知,没有针对此事件的明确事件,但您可以使用暂停事件。每次应用程序进入后台时(按home按钮时就是这种情况),它都被称为。请看一下。我知道,但当我收到消息时,暂停事件处于活动状态,我不希望这样。哦。但如果在收到消息时使用函数onPause或onResume,此函数将激活。我不想在暂停或恢复活动时使用message@NguyễnPhúc您必须使用自己的逻辑处理何时运行暂停和恢复。例如
if(message){//do nothing}其他{//do things}
哦,对不起。我解决了这个错误。谢谢阿基斯。我照你说的做了:)@NguyễnPhúc如果我的答案给了你问题的解决方案,那么你能把它标记为已回答吗?请回答这个问题我被困在这里了哦。但如果在收到消息时使用函数onPause或onResume,此函数将激活。我不想在暂停或恢复活动时使用message@NguyễnPhúc您必须使用自己的逻辑处理何时运行暂停和恢复。例如
if(message){//do nothing}其他{//do things}
哦,对不起。我解决了这个错误。谢谢阿基斯。我照你说的做了:)@NguyễnPhúc如果我的答案给了你问题的解决方案,那么你能把它标记为已回答吗?请回答这个问题,我被困在这里了