Skip to content Skip to sidebar Skip to footer

Use Android Package Manager In Xamarin.forms

Trying to check if a particular application is installed in the android phone or not. In android studio, I used Package manager to get the installation status of the application. B

Solution 1:

yes,you could use DependencyService to achive this:

first,define a Interface :

publicinterfaceIsInstallApplication
 {
     boolIsInstall(string packageName);
 }

then in Droid.project create a class which implement the interface :

[assembly: Dependency(typeof(AndroidIsInstallApplication))]// do not miss the linenamespaceApp18.Droid
{
   classAndroidIsInstallApplication : IsInstallApplication
     {
        publicboolIsInstall(string packageName)
         {
            ... //here you could use Package manager to get the installation status of the application like in native androidreturntrue;
         }
     }
}

finally you could call it in you page like :

DependencyService.Get<IsInstallApplication>().IsInstall(packageName);

Post a Comment for "Use Android Package Manager In Xamarin.forms"