OSDN Git Service

Recheck for shortcut host permission when launching app shortcuts
authorBraden Farmer <farmerbb@gmail.com>
Thu, 9 Mar 2017 05:36:27 +0000 (22:36 -0700)
committerBraden Farmer <farmerbb@gmail.com>
Thu, 9 Mar 2017 05:36:27 +0000 (22:36 -0700)
app/src/main/java/com/farmerbb/taskbar/util/U.java

index 8b35819..692957c 100644 (file)
@@ -507,9 +507,11 @@ public class U {
     private static void launchShortcut(Context context, ShortcutInfo shortcut, Bundle bundle) {
         LauncherApps launcherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
 
-        try {
-            launcherApps.startShortcut(shortcut, null, bundle);
-        } catch (ActivityNotFoundException | NullPointerException e) { /* Gracefully fail */ }
+        if(launcherApps.hasShortcutHostPermission()) {
+            try {
+                launcherApps.startShortcut(shortcut, null, bundle);
+            } catch (ActivityNotFoundException | NullPointerException e) { /* Gracefully fail */ }
+        }
     }
 
     public static void launchAppMaximized(Context context, Intent intent) {