Kaynağa Gözat

Merge branch 'sheep_develop' of 10.8.230.114:xmy_android/small_sheep_android into sheep_develop

hanjing 7 yıl önce
ebeveyn
işleme
7df75e8eec

+ 21 - 0
app/src/main/java/com/sheep/gamegroup/util/SysAppUtil.java

@@ -995,6 +995,27 @@ public class SysAppUtil {
     //是否有快捷方式的权限
     public static boolean hasShortcut(Context context, String appName) {
         LogUtil.println("hasShortcut appName = " + appName);
+        if(Build.VERSION.SDK_INT >=  Build.VERSION_CODES.O){
+            ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE);
+            List<ShortcutInfo> list = shortcutManager.getPinnedShortcuts();
+            if(!ListUtil.isEmpty(list)) {
+                for (ShortcutInfo shortcutInfo : list) {
+                    if(shortcutInfo.getLongLabel() != null && TextUtils.equals(shortcutInfo.getLongLabel().toString(), appName)){
+                        return true;
+                    }
+                }
+            }
+        } else if(Build.VERSION.SDK_INT >=  Build.VERSION_CODES.N_MR1){
+            ShortcutManager systemService = context.getSystemService(ShortcutManager.class);
+            List<ShortcutInfo> list = systemService.getDynamicShortcuts();
+            if(!ListUtil.isEmpty(list)) {
+                for (ShortcutInfo shortcutInfo : list) {
+                    if(shortcutInfo.getLongLabel() != null && TextUtils.equals(shortcutInfo.getLongLabel().toString(), appName)){
+                        return true;
+                    }
+                }
+            }
+        }
         long start = System.currentTimeMillis();
         String authority = getAuthorityFromPermission(context);
         if (authority == null) {