locked
Launching app from protocol - WinJS.Application.onactivated not running RRS feed

  • Question

  • I have setup my app to handle a protocol. If the protocol is called my application will launch and navigate to a specific page. It works fine the first time. But then if I launch a protocol again the application will go to a black screen of death.

    It turns out, that if I launch the app a second time through a protocol, without completely shutting down the app in between, WinJS.Application.onactivated never gets run. onready fires, but not onactivate. Has anyone else ran into this problem?

    (function () {
        "use strict";
    
        WinJS.Binding.optimizeBindingReferences = true;
    
        var app = WinJS.Application;
        var activation = Windows.ApplicationModel.Activation;
    
        app.onactivated = function (args) {
            var url = null;
    
            if (args.detail.kind === activation.ActivationKind.launch) {
                if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                } else {
                    // TODO: This application has been reactivated from suspension.
                    // Restore application state here.
                }
            }
            if (args.detail.kind == activation.ActivationKind.protocol) {
                try {
                    if (args.detail.uri.host == "whiteboard") {
                        // igniteshowcase://whiteboard
                        console.log("Entering Whiteboard mode");
                        url = "/pages/whiteboard/whiteboard.html";
                    }
                }
                // something wrong with the args. Quite possibly not a valid uri. Catch the exception.
                catch (e) {
                    console.log(e.message);
                }
            }
    
            args.setPromise(WinJS.UI.processAll().then(function () {
                IgniteShowcase.initApp();
                IgniteShowcase.activateApp();
                Windows.Storage.ApplicationData.current.localSettings.values.clear();
                if (url) {
                    return WinJS.Navigation.navigate(url);
                }
            }));
        };
    
        app.start();
    })();

    Wednesday, June 12, 2013 7:09 PM