简体   繁体   中英

Android: How to check if my other apps are installed on a device

I have several Android apps in play store and when a user installs one of my apps, how can that app find out that my other apps are installed on this device or not?

I wish to search using : com.developer.* pattern. Can we make such check?

Use this function to find the application using the package name of the application you want.

 private boolean appAvailable(String package_name) {
        PackageManager pm = getPackageManager();
        boolean installed;
        try {
            pm.getPackageInfo(package_name, PackageManager.GET_ACTIVITIES);
            installed = true;
        }
        catch (PackageManager.NameNotFoundException e) {
            installed = false;
        }
        return installed;
    }

Or you can use below function also

public static boolean isAppAvailable(Context context, String packageName) {
    try {
        context.getPackageManager().getApplicationInfo(packageName, 0);
        return true;
    }
    catch (PackageManager.NameNotFoundException e) {
        return false;
    }
}

boolean findFaceebook = isAppAvailable(context, "com.Facebook.katana");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM