locked
Launcher.launchUriAsync is not working in Metro App Launch

    Question

  • Hi,

    I am trying to launch a browser with URI at the time of metro app launching. I added launchUriAsync(uri) in metro app activated event but it is not working.

    If i add the same logic for button event, then it is working but i do not button click. The below is the code. Please advise why it is not working in app launch.

    (function () {
        "use strict";

        var app = WinJS.Application;
        var activation = Windows.ApplicationModel.Activation;
        WinJS.strictProcessing();

        app.onactivated = function (args) {
            if (args.detail.kind === activation.ActivationKind.launch) {

                if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated)
                {
                    // Create the URI to launch from a string.
                    var uri = new Windows.Foundation.Uri(@"http://www.bing.com");

                    // Launch the URI.
                    Windows.System.Launcher.launchUriAsync(uri).done(
                        function (success) {
                            if (success) {
                                WinJS.log && WinJS.log("URI " + uri.absoluteUri + " launched.", "sample", "status");
                            } else {

                                WinJS.log && WinJS.log("URI launch failed.", "sample", "error");
                            }
                        });

                } else {
                    // TODO: This application has been reactivated from suspension.
                    // Restore application state here.
                }
                //args.setPromise(WinJS.UI.processAll());

                args.setPromise(WinJS.UI.processAll());
            }
        };
            
        app.oncheckpoint = function (args) {
            // TODO: This application is about to be suspended. Save any state
            // that needs to persist across suspensions here. You might use the
            // WinJS.Application.sessionState object, which is automatically
            // saved and restored across suspension. If you need to complete an
            // asynchronous operation before your application is suspended, call
            // args.setPromise().
        };
        
        app.start();

    })();

    Regards,

    Venkat.


    Wednesday, June 20, 2012 9:28 AM

Answers

  • Jeff,

    It is working now after calling setTimeout in metro app activated event, then used window.close() after successfully launching IE browser with CRM online url. 

    Regards,

    Venkat.

    • Marked as answer by Dino He Thursday, June 21, 2012 9:13 AM
    • Unmarked as answer by Dino He Thursday, June 21, 2012 9:14 AM
    • Marked as answer by Munaga Venkat Thursday, June 21, 2012 10:35 AM
    Thursday, June 21, 2012 6:04 AM

All replies

  • Hi,

    I am doing a Proof-of-concept to launch CRM online with silent login(username & password should provide before launching) in IE10 from windows 8 metro app with Javascript.

    Please let me know if you have any solution.

    Regards,

    Venkat.


    Wednesday, June 20, 2012 4:26 AM
  • Hi Munaga,

    My first reaction is 'Why would you do this'?  That would be a horrible experience for a user.  If I start your application, I would want to run your applicaiton.  Instead I would be put into a browser.  I would be interested in what your use-case is that you want to do this just for my own knowledge if you would not mind sharing.

    If you really want to do this try using setTimeout and then execute your code to launch the URI.

    -Jeff


    Jeff Sanders (MSFT)

    Wednesday, June 20, 2012 12:35 PM
    Moderator
  • Hi Munaga,

    There is no pre-packaged solution.  If you list what you have tried and what challenges you are facing someone may be able to help you.

    -Jeff


    Jeff Sanders (MSFT)

    Wednesday, June 20, 2012 1:50 PM
    Moderator
  • Hi Jeff,

    Thanks for reply. I want to launch CRM online application in IE browser when user click on the Tile. Please suggest better way to do this scenario.

    I tried as you suggested setTimeout by keep in activated event, it is working first time. If i click on the tile next time, it only launch metro app because Activated event only call at first launching. Is there any event to call setTimeout when click on tile every time.

    Regards,

    Venkat.

     

    Thursday, June 21, 2012 4:16 AM
  • Jeff,

    I am trying the following way to launch CRM Online in IE10.

    Launch CRM online in IE by clicking on Tile - As of now i tried with Launcher.launchUriAsync by passing CRM online url by calling setTimeout on Activated event of metro app. the same i posted in http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/43db9b62-de9a-4452-a813-b4a325ded43b

    Silent CRM online login - After opening CRM online in the browser, i want to do silent login that means take user credentials from config file & auto login into CRM online. please tell if we have any way to achieve. 

    Regards,

    Venkat.

    Thursday, June 21, 2012 4:56 AM
  • Jeff,

    It is working now after calling setTimeout in metro app activated event, then used window.close() after successfully launching IE browser with CRM online url. 

    Regards,

    Venkat.

    • Marked as answer by Dino He Thursday, June 21, 2012 9:13 AM
    • Unmarked as answer by Dino He Thursday, June 21, 2012 9:14 AM
    • Marked as answer by Munaga Venkat Thursday, June 21, 2012 10:35 AM
    Thursday, June 21, 2012 6:04 AM