-1

Is there any way to check if the particular application is already installed in device ? May be through some package name ?

Regards

user45678
  • 1,504
  • 6
  • 29
  • 58

2 Answers2

2

try like this:

public void checkApplication(String packageName) {
    PackageManager packageManager = getPackageManager();
    ApplicationInfo applicationInfo = null;
    try {
        applicationInfo = packageManager.getApplicationInfo(packageName, 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    if (applicationInfo == null) {
        // not installed
    } else {
        // Installed
    }
}
Rathan Kumar
  • 2,567
  • 2
  • 17
  • 24
1

check this:

add packagename in targetPackage of checking application .

public boolean isPackageExisted(String targetPackage){
        List<ApplicationInfo> packages;
        PackageManager pm;
            pm = getPackageManager();        
            packages = pm.getInstalledApplications(0);
            for (ApplicationInfo packageInfo : packages) {
        if(packageInfo.packageName.equals(targetPackage)) return true;
        }        
        return false;
    }
KDeogharkar
  • 10,939
  • 7
  • 51
  • 95