0
This is the function that when installing does not work.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("backbutton", onBackKeyDown, false);//quando ele clicar no botao de voltar
}
function onBackKeyDown(e) {
if (overlayVisible) {
e.preventDefault();
hideOverlay();
}
else {
navigator.notification.confirm("Você deseja sair do aplicativo?", onConfirm, "Confirmação", "Sim,Não");
// alerta de confirmação para sair do aplicativo
}
}
function onConfirm(button) {
if (button == 2) {//Se o usuario escolher nao simplesmente nao fara nada
return;
}
else {
navigator.app.exitApp();// Caso contrario sair do app.
}
}
When I do the phonegap command line test it works normally but after generated the APK does not work... Help Please!
– Paulo Lelis
But other functions work or no function works after APK is generated?
– Pedro Henrique
All others work. until if works, except Else.
– Paulo Lelis
Which is not working on the
onConfirm
or that ofonBackKeyDown
. You can also tell me more about the variableoverlayVisible
? If it really changes its state at any time.– Pedro Henrique
The Else that does not work is that of onBackKeyDown, when I test it by the phonegap application works normally but when installed on the device it stops working. overlayVisible changes its state when I click on any photo present in the application it changes from false to true when any image is open. I put in the Github the full JS where there is this function.
– Paulo Lelis
I did some tests on your application and there really are problems. What I can recommend is that you treat differently the events of the end of the application. I noticed you modified a plugin
JS
adding Cordova codes to your logic, you should separate a little what each file has and does, even more to make support easier. I tried to make a separation, but still found problems. Makes some form of delegation of events cleaner. Anything just let me know I’ll give you a hand.– Pedro Henrique