Windows Phone Launcher class

Starts the default app associated with the specified file or URI.

Launch a file contained in the app package

async void DefaultLaunch()

{

   // Path to the file in the app package to launch

   string imageFile = @"images\test.png";



   var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);



   if (file != null)

   {

      // Launch the retrieved file

      var success = await Windows.System.Launcher.LaunchFileAsync(file);



      if (success)

      {

         // File launched

      }

      else

      {

         // File launch failed

      }

   }

   else

   {

      // Could not find file

   }

}

 

Launch a URI

// The URI to launch

string uriToLaunch = @"http://www.bing.com";



// Create a Uri object from a URI string 

var uri = new Uri(uriToLaunch);



// Launch the URI

async void DefaultLaunch()

{

   // Launch the URI

   var success = await Windows.System.Launcher.LaunchUriAsync(uri);



   if (success)

   {

      // URI launched

   }

   else

   {

      // URI launch failed

   }

}

你可能感兴趣的:(windows phone)