4

In Xamarin Android, I use implicit intents to load another app. This can be the browser or whatever. If I want to load i.e. a Facebook link, the OS allows me to choose to use a browser or specifically the Facebook App. This is also the case for a few other links where the page owners have produced an app.

Is there a way to find out if a specific app, say the Stack Overflow app, is installed on the current mobile device?

Kat Seiko
  • 125
  • 9
  • duplicate? http://stackoverflow.com/questions/11392183/how-to-check-programmatically-if-an-application-is-installed-or-not-in-android – jdmdevdotnet Nov 04 '16 at 21:57

1 Answers1

6

Yep, here's a Xamarin/C# function that will tell you if a specific app (via its package name) is installed:

public bool IsAppInstalled(string packageName) {
    try {
        PackageManager.GetPackageInfo(packageName, PackageInfoFlags.Activities);
        return true;
    }
    catch (PackageManager.NameNotFoundException ex) {
        return false;
    }
}

Example call:

bool bIsAppInstalled = IsAppInstalled("com.theirdomain.someapp");
Robert Bruce
  • 1,088
  • 1
  • 13
  • 17