locked
NetworkInfo exit application RRS feed

  • Question

  • The application is based on JavaScript and on internet connectivity.

    On application launch if there is no connection to the internet I want a popup message to show and afterwards exit the application.

    How do I achieve this?

    Thursday, August 16, 2012 10:19 AM

Answers

All replies

  • See the Network information sample:

    http://code.msdn.microsoft.com/windowsapps/Network-Information-Sample-63aaa201


    Jeff Sanders (MSFT)

    Thursday, August 16, 2012 6:21 PM
    Moderator
  • I tried the sample but I get some errors on my Application. I need a more complicated example than the sample provided.

    The application as I mentioned is in JavaScript based on Grid App Visual Studio Template.

    On application launch the data.js is loaded which queries (using WinJS.xhr) a web service to provide data.
    If I disable the network adapter the debugger stops on base.js:

    var terminateAppHandler = function (data) {
            debugger;
            MSApp.terminateApp(data);
        };
    Even if I use the networkInfo.getInternetConnectionProfile() to check before if to call the web service, the application keeps throwing errors on base.js 

     

    Friday, August 17, 2012 8:39 AM
  • What is the callstack when you get the error?  What does the JavaScript console say?  Have you stepped through all your code before the error?  Did you verify you do not call WinJS.xhr when there is no network connection?

    Jeff Sanders (MSFT)

    Friday, August 17, 2012 12:44 PM
    Moderator