Abhi
Abhi

Reputation: 29

How to check an App is installed or not using MAUI App?

Need to check one App is installed or not. Tried with below code, but its not working in .net MAUI App. Any alternate solution?

    [Obsolete]
    private bool isAppInstalled(String packageName)
    {

        PackageManager pm = this.PackageManager;

        bool installed = false;
        try
        {
            pm.GetPackageInfo(packageName, PackageInfoFlags.Activities);
            installed = true;

        }
        catch (Exception e)
        {
            installed = false;
        }
        return installed;
    }

Eg: trying to check Google Pay is installed or not:

  Boolean result = isAppInstalled("com.google.android.apps.nbu.paisa.user");

Its always return false, even if the app is installed.

Upvotes: 0

Views: 642

Answers (1)

Liyun Zhang - MSFT
Liyun Zhang - MSFT

Reputation: 14244

Add <queries> tag for the app package you want check in the \Platforms\Android\AndroidManifest. Such as:

<manifest>
    <queries>
        <package android:name="com.google.android.apps.nbu.paisa.user"/>
    </queries>

Upvotes: 2

Related Questions