Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exit or quit my Windows Phone 8 app programmatically?

I am developing a Windows Phone 8 application.

  1. How can I exit or quit programmatically (through code) from my Windows Phone 8 app?

  2. What are the various ways in which I can programmatically (through code) exit or quit from my Windows Phone 8 app?

like image 352
user1516781 Avatar asked Feb 24 '13 13:02

user1516781


People also ask

How do you exit an app?

You can call System. exit(); to get out of all the acivities.

How do you end an app on Android?

To Close the Application, you can also take "System. exit(0)" 0 is standard or use any exit code.

How do I exit UWP app?

TryConsolidateAsync() to close the app. The obvious benefit of this method is app is closed just as you will do by pressing close button in titlebar, the closing is graceful, animation is the same and app is suspended instead of abruptly exiting.


2 Answers

In WP8 there's a new API which lets you terminate the application:

Application.Current.Terminate();

By calling the method your app will immediatelly terminate. However the Application_Closing event won't be called, and IsolatedStorageSettings.ApplicationSettings dictionary won't be automatically persisted.

So if you have data hanging around in IsolatedStorageSettings.ApplicationSettings that you don't want to lose then it's wise to save it:

IsolatedStorageSettings.ApplicationSettings.Save();
Application.Current.Terminate();

Also the method should not be misused. See http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.application.terminate(v=vs.105).aspx for more info for legitimate use cases.

like image 98
krdx Avatar answered Oct 08 '22 05:10

krdx


while (((PhoneApplicationFrame)App.Current.RootVisual).CanGoBack)
{
    ((PhoneApplicationFrame)App.Current.RootVisual).RemoveBackEntry();
}
like image 43
Alex Ovechkin Avatar answered Oct 08 '22 05:10

Alex Ovechkin