Function does not work after installed the application

Asked

Viewed 147 times

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!

  • But other functions work or no function works after APK is generated?

  • All others work. until if works, except Else.

  • Which is not working on the onConfirm or that of onBackKeyDown. You can also tell me more about the variable overlayVisible? If it really changes its state at any time.

  • 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.

  • 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 JSadding 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.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.