Skip to content Skip to sidebar Skip to footer

Detecting Programmatically Whether An App Is Installed On Android

I have registered a url scheme for my Android app (let's say myapp://host). On my other app, I can launch that app by using Intent, but how do I check whether the first app is inst

Solution 1:

If you know how to launch the app, then create the intent that launches your app and then call queryIntentActivities

Intentintent=//your app launching intent goes herePackageManagerpackageManager= mContext.getPackageManager();
 List<ResolveInfo> resolvedActivities = packageManager.queryIntentActivities(intent,0);
 if(resolvedActivities.size() >0)
     \\present

Solution 2:

I use queryIntentActivities from class PackageManager in a static method :

publicstaticbooleancanOpenIntent(Context context, Intent intent)
{
    booleancanOpenUrl=false;
    PackageManagerpackageManager= context.getPackageManager();
    List<ResolveInfo> resolvedActivities = packageManager.queryIntentActivities(intent, 0);
    if(resolvedActivities.size() > 0)
        canOpenUrl = true;
    return canOpenUrl;
}

Post a Comment for "Detecting Programmatically Whether An App Is Installed On Android"