@Test @SmallTest @SdkSuppress(minSdkVersion = 26) public void testCreateShortcutResultIntent_v26() throws Throwable { ShortcutManager mockShortcutManager = mock(ShortcutManager.class); doReturn(mockShortcutManager).when(mContext).getSystemService(eq(Context.SHORTCUT_SERVICE)); when(mockShortcutManager.createShortcutResultIntent(any(ShortcutInfo.class))) .thenReturn(new Intent("some-dummy-action")); Intent result = ShortcutManagerCompat.createShortcutResultIntent(mContext, mInfoCompat); verifyLegacyIntent(result); assertEquals("some-dummy-action", result.getAction()); ArgumentCaptor<ShortcutInfo> captor = ArgumentCaptor.forClass(ShortcutInfo.class); verify(mockShortcutManager, times(1)).createShortcutResultIntent(captor.capture()); assertEquals("test-id", captor.getValue().getId()); }
@NonNull public static Intent createShortcutResultIntent(@NonNull Context context, @NonNull ShortcutInfoCompat shortcut) { Intent result = null; if (Build.VERSION.SDK_INT >= 26) { result = context.getSystemService(ShortcutManager.class) .createShortcutResultIntent(shortcut.toShortcutInfo()); } if (result == null) { result = new Intent(); } return shortcut.addToIntent(result); }
ShortcutManagerCompat { @NonNull public static Intent createShortcutResultIntent(@NonNull Context context, @NonNull ShortcutInfoCompat shortcut) { Intent result = null; if (Build.VERSION.SDK_INT >= 26) { result = context.getSystemService(ShortcutManager.class) .createShortcutResultIntent(shortcut.toShortcutInfo()); } if (result == null) { result = new Intent(); } return shortcut.addToIntent(result); } }
ShortcutManagerCompat { @NonNull public static Intent createShortcutResultIntent(@NonNull Context context, @NonNull ShortcutInfoCompat shortcut) { Intent result = null; if (Build.VERSION.SDK_INT >= 26) { result = context.getSystemService(ShortcutManager.class) .createShortcutResultIntent(shortcut.toShortcutInfo()); } if (result == null) { result = new Intent(); } return shortcut.addToIntent(result); } private  ShortcutManagerCompat(); }
ShortcutManagerCompat { @NonNull public static Intent createShortcutResultIntent(@NonNull Context context, @NonNull ShortcutInfoCompat shortcut) { Intent result = null; if (Build.VERSION.SDK_INT >= 26) { result = context.getSystemService(ShortcutManager.class) .createShortcutResultIntent(shortcut.toShortcutInfo()); } if (result == null) { result = new Intent(); } return shortcut.addToIntent(result); } private  ShortcutManagerCompat(); static boolean isRequestPinShortcutSupported(@NonNull Context context); static boolean requestPinShortcut(@NonNull final Context context,
            @NonNull ShortcutInfoCompat shortcut, @Nullable final IntentSender callback); @NonNull static Intent createShortcutResultIntent(@NonNull Context context,
            @NonNull ShortcutInfoCompat shortcut); }
ShortcutManagerCompat { @NonNull public static Intent createShortcutResultIntent(@NonNull Context context, @NonNull ShortcutInfoCompat shortcut) { Intent result = null; if (Build.VERSION.SDK_INT >= 26) { result = context.getSystemService(ShortcutManager.class) .createShortcutResultIntent(shortcut.toShortcutInfo()); } if (result == null) { result = new Intent(); } return shortcut.addToIntent(result); } private  ShortcutManagerCompat(); static boolean isRequestPinShortcutSupported(@NonNull Context context); static boolean requestPinShortcut(@NonNull final Context context,
            @NonNull ShortcutInfoCompat shortcut, @Nullable final IntentSender callback); @NonNull static Intent createShortcutResultIntent(@NonNull Context context,
            @NonNull ShortcutInfoCompat shortcut);  }