title: Xamarin Forms: How to open an app from another app?
body: <p>I have 2 applications ( A and B ) developed using Xamarin.Forms. I need to open app A from app B.</p>
  <p>I have tried like below as per this <a href="https://forums.xamarin.com/discussion/92666/detect-and-open-another-app-on-device" rel="noreferrer">thread</a>:</p>
  <p><strong>In the view</strong></p>
  <pre><code>var appname = @&quot;otherappId&quot;;
  var result = await DependencyService.Get&lt;IAppHandler&gt;().LaunchApp(appname);
  </code></pre>
  <p><strong>Interface</strong></p>
  <pre><code>public interface IAppHandler
  {
      Task&lt;bool&gt; LaunchApp(string uri);
  }
  </code></pre>
  <p><strong>Android</strong></p>
  <pre><code>[Activity(Label = &quot;OpenAppAndroid&quot;)]
  public class OpenAppAndroid : Activity, IAppHandler
  {
      public Task&lt;bool&gt; LaunchApp(string uri)
      {
          bool result = false;
  
          try
          {
              var aUri = Android.Net.Uri.Parse(uri.ToString());
              var intent = new Intent(Intent.ActionView, aUri);
              Xamarin.Forms.Forms.Context.StartActivity(intent);
              result = true;
          }
          catch (ActivityNotFoundException)
          {
              result = false;
          }
  
          return Task.FromResult(result);
      }
  }
  </code></pre>
  <p><strong>IOS</strong></p>
  <pre><code>public class OpenAppiOS : IAppHandler
  {
      public Task&lt;bool&gt; LaunchApp(string uri)
      {
          try
          {
              var canOpen = UIApplication.SharedApplication.CanOpenUrl(new NSUrl(uri));
  
              if (!canOpen)
                  return Task.FromResult(false);
  
              return Task.FromResult(UIApplication.SharedApplication.OpenUrl(new NSUrl(uri)));
  
          }
          catch (Exception ex)
          {
              return Task.FromResult(false);
          }
      }
  </code></pre>
  <ol>
  <li><p>For android, I am getting <code>System.NullReferenceException: 'Object reference not set to an instance of an object.'</code> when running the project. I don't know what is app name in the code? I have tried with the package name.</p>
  </li>
  <li><p>Also if the android app is not installed on the device, it needs to open the Play Store to download the app.</p>
  </li>
  <li><p>I didn't test the iOS part because Mac is not available. Is the above code work for iOS? Also if the app is not installed on the iPhone, need to open the AppStore to download the app.</p>
  </li>
  <li><p>Also, I like to implement the same for UWP.</p>
  </li>
  </ol>
  <p>Reference:
  <a href="https://forums.xamarin.com/discussion/92666/detect-and-open-another-app-on-device" rel="noreferrer">https://forums.xamarin.com/discussion/92666/detect-and-open-another-app-on-device</a>
  <a href="https://stackoverflow.com/questions/52062594/is-it-possible-to-open-another-app-in-my-app-with-xamarin-form">Is it possible to open another app in my app with xamarin.form?</a></p>