This commit is contained in:
wangcongtao
2020-06-03 11:16:03 +08:00
parent ac7fd86306
commit c4d3d2f7e2
109 changed files with 612 additions and 70 deletions

View File

@@ -3,6 +3,9 @@ package com.mogo.utils;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import java.util.List;
@@ -25,4 +28,22 @@ public class AppUtils {
}
return false;
}
public static boolean isAppInstalled( Context context, String pkg ) {
PackageInfo packageInfo;
if ( TextUtils.isEmpty( pkg ) ) {
return false;
}
try {
packageInfo = context.getPackageManager().getPackageInfo( pkg, 0 );
} catch ( PackageManager.NameNotFoundException e ) {
packageInfo = null;
e.printStackTrace();
}
if ( packageInfo == null ) {
return false;
} else {
return true;
}
}
}