Ok so I have an Android app where I want to check to see if an app name that is installed matches a string passed to the function containing this code. The code and example is below:
private Boolean checkInstalledApp(String appName){
PackageManager pm = this.getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0);
Boolean isInstalled = false;
for(ResolveInfo info: list) {
if (info.activityInfo.applicationInfo.loadLabel( pm ).toString()==appName){
isInstalled = true;
break;
}
}
return isInstalled;
}
Assuming you called checkInstalledApp('SetCPU'); and the app name on the phone is called the same thing it should return true. However, it never does. I logged the results and it should match up but it does not. Can anyone please enlighten me as to why this doesn't work?