android⼀IOS SDK怎么判断用户是否安装了微信⼀QQ

2025-04-02 10:49:01
推荐回答(2个)
回答1:

Android系统中,判断应用有无安装有两种方式:
1.根据包名判断,以下为判断代码:
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”.equals(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager()
.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}

2. 根据Intent判断,以下为判断代码:
public boolean checkApkExist(Context context, Intent intent) {
List list = context.getPackageManager().queryIntentActivities(intent, 0);
if(list.size() > 0){
return true;
}
return false;
}
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”.equals(packageName)) return false;
try {
ApplicationInfo info = context.getPackageManager() .getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); return true;
} catch (NameNotFoundException e) { return false; }
}
public boolean checkApkExist(Context context, Intent intent) {
List list = context.getPackageManager()
.queryIntentActivities(intent, 0);
if (list.size() > 0) {
return true;
}
return false;
}

回答2:

Android 里面有个权限叫做:获取以知安装应用程序。
会有一个返回值。

希望能帮到你。