×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    25

    Question Closing Windows Phone 8 apps programatically

    I searched for away to close Windows Phone 8 app programmatically and found 2 Ways :

    1 - By throwing Exception like this:

    http://blog.roboblob.com/2012/08/19/...grammatically/

    Which is not suitable way and not working always.

    2- By using XNA Game Exit like this:

    http://blog.roboblob.com/2012/08/21/...e-application/

    And I cannot use it in Windows Phone 8.


    Is there is any new idea or way suitable for Windows Phone 8?

  2. #2
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    295

    Re: Closing Windows Phone 8 apps programatically

    On windows phone 8, there is a new method which help you terminate/exit the app. Application.Current.Terminate();
    (I didn't test it yet, can you give us some feedback after trying it)

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    25

    Re: Closing Windows Phone 8 apps programatically

    Quote Originally Posted by Loukt View Post
    On windows phone 8, there is a new method which help you terminate/exit the app. Application.Current.Terminate();
    (I didn't test it yet, can you give us some feedback after trying it)
    Thanks LouKt, it works prefectly

  4. #4
    Registered User
    Join Date
    Mar 2013
    Posts
    12

    Re: Closing Windows Phone 8 apps programatically

    Application.Current.Terminate() is only allowed in very limited circumstances. Otherwise your app won't pass certification. See the documentation: http://msdn.microsoft.com/en-US/libr...v=vs.105).aspx

    This method should only be used in cases where the user is unable to make any useful forward progress such as if the user is presented with an End User License Agreement and declines or if the app requires the user to login and the user can’t provide credentials. Otherwise, apps should not use this method to provide an “Exit” mechanism.
    In Windows Phone (just like Android and iOS), you should take the approach that a user will "quit" your app by simply switching another app.
    Last edited by Metro Developer; 2013-03-15 at 04:19.

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    508

    Re: Closing Windows Phone 8 apps programatically

    We discussed this issue with MS Developers during the WP8 Beta Preview program and came up with several use cases where closing an App in that way made perfect sense and caused no issues with certification. One example would be the Shortcut Apps. They open at a certain URL and forward users to the selected settings. When the Back button is pressed the user should not arrive at the gateway page he never saw in the first place but get back to the Home screen where he started out. Application.Current.Terminate in that case gives you the behavior the user was expecting anyway. That is the guideline underlying the usage of Application.Current.Exit: will it achieve behavior consitent with what the user would expect to happen based on how other apps (especially system apps) work in that situation.

    Raising an exception to crash the App might give you problems in certification even if the behavior was intended.

    The biggest problem with Application.Current.Terminate seems to be that it does not raise Application Live Cycle Events like "NavigatedFrom" or "App.Exiting" so you will have to ensure that all data is saved properly before exiting in that way.

Similar Threads

  1. Porting the classic Nokia games/apps to Windows Phone
    By alexstrand7 in forum Windows Phone General
    Replies: 2
    Last Post: 2012-03-31, 05:22
  2. Windows Phone Apps numbers growing faster than expected
    By joaocardoso in forum News and Announcements
    Replies: 3
    Last Post: 2012-01-27, 02:35
  3. Can we publish Windows Phone 7 apps to Ovi store?
    By ducnd in forum Windows Phone General
    Replies: 4
    Last Post: 2011-10-31, 07:43
  4. Partnership with Nokia concerning apps for the Windows Phone 7
    By ArchieCoder in forum Windows Phone General
    Replies: 11
    Last Post: 2011-09-12, 09:21
  5. closing message window programatically
    By JasonSmithMiller in forum Symbian
    Replies: 3
    Last Post: 2008-09-09, 14:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×