package io.github.droidkaigi.confsched2017.util;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;

import java.util.Collections;

import io.github.droidkaigi.confsched2017.R;
import io.github.droidkaigi.confsched2017.view.activity.MainActivity;
import io.github.droidkaigi.confsched2017.view.activity.SearchActivity;

public class AppShortcutsUtil {

    private static final String APP_SHORTCUTS_SEARCH_ID = "search";

    @RequiresApi(api = Build.VERSION_CODES.N_MR1)
    public static void addShortcuts(@NonNull Context context) {
        ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE);

        Intent[] intents = {
                new Intent(context.getApplicationContext(), MainActivity.class).setAction(Intent.ACTION_DEFAULT),
                new Intent(context.getApplicationContext(), SearchActivity.class).setAction(Intent.ACTION_DEFAULT)
        };

        ShortcutInfo shortcutInfo = new ShortcutInfo.Builder(context, APP_SHORTCUTS_SEARCH_ID)
                .setShortLabel(context.getString(R.string.shortcut_search_title))
                .setIcon(Icon.createWithResource(context, R.drawable.ic_shortcut_search_24_vector))
                .setIntents(intents)
                .build();

        shortcutManager.addDynamicShortcuts(Collections.singletonList(shortcutInfo));
    }
}

@@ -888,24 +888,67 @@
 _SERVICE);%0A%0A
+        if (shortcutManager != null) %7B%0A    
         Inte
@@ -972,32 +972,36 @@
                 
+  
+  
 new Intent(conte
@@ -1082,16 +1082,20 @@
 FAULT),%0A
+    
         
@@ -1209,16 +1209,20 @@
         
+    
 %7D;%0A%0A    
@@ -1217,32 +1217,36 @@
     %7D;%0A%0A        
+ 
+   
 ShortcutInfo sho
@@ -1328,24 +1328,28 @@
             
+    
 .setShortLab
@@ -1402,16 +1402,20 @@
 title))%0A
+    
         
@@ -1518,24 +1518,28 @@
             
+    
 .setIntents(
@@ -1563,16 +1563,20 @@
         
+    
 .build()
@@ -1574,24 +1574,28 @@
  .build();%0A%0A
+    
         shor
@@ -1668,16 +1668,26 @@
 Info));%0A
+        %7D%0A
     %7D%0A%7D%0A

Add null check