0

有没有办法根据包名检查手机上是否安装了某些应用程序?例如,您的手机上安装了 com.google.maps。用户将输入包名称,单击应用程序内的应用程序或类似按钮的扫描按钮,如果安装了应用程序,则会说该应用程序已安装。

4

1 回答 1

3

无论从detect-an-application-is-installed-or-not测试此代码:

    isAppInstalled("com.simexusa.campusmaps_full");

private boolean isAppInstalled(String packageName) {
    PackageManager pm = getPackageManager();
    boolean installed = false;
    try {
       pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
       installed = true;
    } catch (PackageManager.NameNotFoundException e) {
       installed = false;
    }
    return installed;
}
于 2013-10-20T08:27:19.720 回答