feat: 优化包名获取逻辑

This commit is contained in:
chenjuntao
2024-06-26 11:46:23 +08:00
parent 398ff16f76
commit b4e2685f19
9 changed files with 183 additions and 112 deletions

View File

@ -768,10 +768,10 @@ public class LibaoUtils {
}
public static boolean isAppInstalled(Context context, String packageName) {
List<PackageInfo> pinfo = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
if (pinfo != null) {
for (int i = 0; i < pinfo.size(); i++) {
String pn = pinfo.get(i).packageName;
List<String> packageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(context, 0);
if (packageNameList != null) {
for (int i = 0; i < packageNameList.size(); i++) {
String pn = packageNameList.get(i);
if (pn.equals(packageName)) {
return true;
}