Skip to content

Run External App

levching edited this page Apr 15, 2020 · 3 revisions

In order to perform such an action, you need to use a combination of AN_Activity, AN_Intent, and AN_PackageManager classes. See the example below.

using SA.Android.App;
using SA.Android.Content;
using SA.Android.Content.Pm;
...

var pm = AN_MainActivity.Instance.GetPackageManager();
AN_Intent startAppIntent = pm.GetLaunchIntentForPackage("com.facebook.katana");
if(startAppIntent == null) {
    AN_Logger.Log("App with Id: com.facebook.katana not found on device");
    return;
}
startAppIntent.AddCategory(AN_Intent.CATEGORY_LAUNCHER);

AN_MainActivity.Instance.StartActivity(startAppIntent);

You can learn more about how the Package manager may be used with the PackageManager Guide.

Clone this wiki locally