有没有办法检查Android应用程序是否通过另一个Android应用程序安装在设备中,即使用户已将其从他/她的Android设备中删除
例如: - 让我们假设一个用户安装了Android应用程序A并将其从他/她的设备中删除。现在我已经安装了一个Android应用程序B.如果用户安装了应用程序A,那么有没有办法检查应用程序B
答案 0 :(得分:-1)
please try this method its return whether application is install or not but just you need to pass package name of your app.
private boolean isPackageInstalled(String packagename, Context context) {
PackageManager pm = context.getPackageManager();
try {
pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
答案 1 :(得分:-2)
试试这个......
final PackageManager packageManager = getPackageManager();
List<ApplicationInfo> AppPackages = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo AppPackageInfo : AppPackages) {
Log.d(TAG, "Installed App Package :" + AppPackageInfo.packageName);
Log.d(TAG, "Launch Activity :" + packageManager.getLaunchIntentForPackage(AppPackageInfo.packageName));
}
<强>已更新强>
private boolean isAppInstalled(String appPackage) {
boolean isAppExists = false;
PackageManager packageManager = getPackageManager();
List<ApplicationInfo> AppPackages = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo appPackageInfo : AppPackages) {
if (appPackageInfo.packageName.equalsIgnoreCase(appPackage)) {
isAppExists = true;
break;
} else {
isAppExists = false;
}
}
return isAppExists;
}
在这里,您需要使用应用程序包名称(您想知道的应用程序)调用该方法