Aiko West
Aiko West

Reputation: 791

Xamarin Android : Check if Microsoft Word is installed

I am trying to check programmatically if Microsoft Word (Excel, etc.) from the Playstore is installed on my current device.

I tried to check the installed package with this method:

private bool isPackageInstalled(string packagename)
{
    PackageManager pm = Context.PackageManager;
    bool installed = false;
    try
    {
        pm.GetPackageInfo(packagename, PackageInfoFlags.Activities);
        installed = true;
    }
    catch (PackageManager.NameNotFoundException e)
    {
        installed = false;
    }
    return installed;
}

But I've had no success. I tried msword and application/msword as packagenames.

Can someone tell me what are the correct packag enames to check the apps, if the method is not correct, or if there is another, maybe even simpler way to check this?

Upvotes: 1

Views: 331

Answers (1)

Michał Żołnieruk
Michał Żołnieruk

Reputation: 2105

Your method seems to be fine, you just need correct package name, for Microsoft Word it's com.microsoft.office.word. One easy way to find it is looking online at google play store, it's included in the link:

https://play.google.com/store/apps/details?id=**PACKAGE_NAME**

for example:

  • play.google.com/store/apps/details?id=com.microsoft.office.word
  • play.google.com/store/apps/details?id=com.microsoft.office.excel
  • play.google.com/store/apps/details?id=com.microsoft.office.powerpoint

Upvotes: 4

Related Questions