[英]How to check if an android application was installed even if it is removed from the device
Is there a way to check whether an android application was installed in the device through another android app, even if the user has removed it from his/her android device 有没有一种方法可以检查是否通过另一个Android应用程序在设备中安装了Android应用程序,即使用户已将其从其Android设备中删除
For eg:- Let us suppose a user has installed android app A and removed it from his/her device. 例如:-让我们假设一个用户已经安装了android app A并将其从他/她的设备中删除。 Now I have installed an Android app B.Is there a way to check through application B, if the user had installed app A
现在我已经安装了Android应用B,如果用户已经安装了应用A,有没有办法检查应用B
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;
}
}
Try this... 尝试这个...
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));
}
UPDATED 更新
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;
}
Here you need to call the method with app package name(the app which you wants to know) 在这里,您需要使用应用程序包名称(您想知道的应用程序)调用该方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.