How to exit the application in the phone window 8 with a phone screen saver 2.3

My question is how to exit the application in window phone 8 using the phone screen saver 2.3.
I used "navigatior.app.exit ()", but it shows that "navigatior.app" is undefined.

+3
source share
3 answers

I think I found a solution that does not require my own hack.

If you have a Phonegap / cordova application that goes from page1.html to page2.html, then a link to page1.html follows, the standard default behavior will not exit the application.

Page1 → Page 2 → Page 1 - Windows Phone will take you to page 2 instead of exiting the application. His expected behavior, but his appearance is poorly documented.

In any case, I searched around for ages, but did not find a fix that worked for me.

Lightweight friendly people see a commit that includes this fix

TL; DR, as I fixed it, use the JS value to track which page Im on, if I'm on the index page I reset the history, then I allow the buttons on the back panel to function.

IE in page1.html you could ..

var currentPage = "index"; 

Then they enter your app.deviceready function.

 if(currentPage == "index"){ history.go(-(history.length-9999)); document.addEventListener("backbutton", handleBack, true); }else{ document.addEventListener("backbutton", handleBack, false); } function handleBack(){ // handle other logic here such as handling the back events from page2 to page1.. } 

The real magic here is history.go (- (history.length-9999)), which basically tells the history stack to reset. Also, the true addEventListener operator allows you to trigger the original registered event (the "Native back" button).

In any case, try and let me know if this works for you.

A source

0
source
  protected IsolatedStorageSettings UserSettings { get { return IsolatedStorageSettings.ApplicationSettings; } } void OnAppExit(object sender, EventArgs e) { UserSettings.Remove("sessionStorage"); UserSettings.Save(); } private void Page_BackKeyPress(object sender, CancelEventArgs e) { if (_browserHistoryLength > 1) { _phoneGapView.Browser.InvokeScript("eval", "history.go(-1)"); _browserHistoryLength -= 2; e.Cancel = true; } else { //to exit app Application.Current.Exit += new EventHandler(OnAppExit); } } 
0
source

Navigator.app.exit () does not work if the plugin is not defined by Cordova frameowork. You may need to write your own plugin for the Exit method to make it work. As a workaround, your hardware back-key event can be handled in Cordova.xaml.cs, and to exit the application you can write **

 Application.Current.Terminate(); 

It will exit the application when you click on the hardware stand.

-2
source

Source: https://habr.com/ru/post/950638/


All Articles