简体   繁体   中英

How to Launch a Built In App from within Application

I'd like to allow a user to manage their WiFi settings from a pinned tile on the start screen. I have set up the tile to pin properly, but I check this in the app's MainPage OnNavigatedTo event. Everything works, except when you launch from the secondary tile you can see the actual application load for a split second before the built in WiFi app is launched. All of the other apps I see with this functionality do not have this issue. I would like to avoid this but I am not sure where to place my code in doing so?

MainPage.xaml.cs

protected async override void OnNavigatedTo(NavigationEventArgs e)
    {
        if (fromTile == true) //flag to force the app to close if navigating back from Built in App
            App.Current.Terminate();

        //From Pinned Tile
        if (NavigationContext.QueryString.ContainsKey(Constants.Key))
        {
            string _title = null;
            _title = NavigationContext.QueryString[Constants.Key];

            if (_title != null)
            {
                switch (_title)
                {
                    case "Tile_WiFi":
                        await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-wifi:"));

                    .. do more stuff ..
                }

                NavigationContext.QueryString.Remove(Constants.Key);
                fromTile = true;
            }
        }
    }

EDIT*

When placing this code in the constructor I get an System.AccessViolationException on line NavigationContext.QueryString.ContainsKey(Constants.Key) stating Attempt to read or write protected memory.

Please refer the following link to achieve your rquirement,

http://abundantcode.com/how-to-launch-the-device-wifi-settings-app-from-the-windows-phone-8-app/

Regards, Riyaj Ahamed I

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM