Skip to content

Commit cca3150

Browse files
committed
see 09/29 log
1 parent 807e58a commit cca3150

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

utilcode/src/main/java/com/blankj/utilcode/util/AppUtils.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import android.app.Activity;
55
import android.app.ActivityManager;
66
import android.content.Context;
7+
import android.content.Intent;
78
import android.content.pm.ApplicationInfo;
89
import android.content.pm.PackageInfo;
910
import android.content.pm.PackageManager;
11+
import android.content.pm.ResolveInfo;
1012
import android.content.pm.Signature;
1113
import android.graphics.drawable.Drawable;
1214
import android.util.Log;
@@ -29,6 +31,21 @@ private AppUtils() {
2931
throw new UnsupportedOperationException("u can't instantiate me...");
3032
}
3133

34+
/**
35+
* 判断App是否安装
36+
*
37+
* @param action action
38+
* @param category category
39+
* @return {@code true}: 已安装<br>{@code false}: 未安装
40+
*/
41+
public static boolean isInstallApp(final String action, final String category) {
42+
Intent intent = new Intent(action);
43+
intent.addCategory(category);
44+
PackageManager pm = Utils.getApp().getPackageManager();
45+
ResolveInfo info = pm.resolveActivity(intent, 0);
46+
return info != null;
47+
}
48+
3249
/**
3350
* 判断App是否安装
3451
*

0 commit comments

Comments
 (0)