@Test @Config(sdk = 24) public void doesNothingBeforeApi25() { Shortbread.create(activity); verifyNoMoreInteractions(activity); }
@TargetApi(25) public static void create(@NonNull Context context) { if (Build.VERSION.SDK_INT < 25) { return; } if (generated == null) { try { generated = Class.forName("shortbread.ShortbreadGenerated"); createShortcuts = generated.getMethod("createShortcuts", Context.class); callMethodShortcut = generated.getMethod("callMethodShortcut", Activity.class); } catch (ClassNotFoundException e) { Log.i(Shortbread.class.getSimpleName(), "No shortcuts found"); } catch (NoSuchMethodException e) { e.printStackTrace(); } } Context applicationContext = context.getApplicationContext(); if (!shortcutsSet) { setShortcuts(applicationContext); } if (!activityLifecycleCallbacksSet) { setActivityLifecycleCallbacks(applicationContext); } if (context instanceof Activity) { callMethodShortcut((Activity) context); } }
Shortbread { @TargetApi(25) public static void create(@NonNull Context context) { if (Build.VERSION.SDK_INT < 25) { return; } if (generated == null) { try { generated = Class.forName("shortbread.ShortbreadGenerated"); createShortcuts = generated.getMethod("createShortcuts", Context.class); callMethodShortcut = generated.getMethod("callMethodShortcut", Activity.class); } catch (ClassNotFoundException e) { Log.i(Shortbread.class.getSimpleName(), "No shortcuts found"); } catch (NoSuchMethodException e) { e.printStackTrace(); } } Context applicationContext = context.getApplicationContext(); if (!shortcutsSet) { setShortcuts(applicationContext); } if (!activityLifecycleCallbacksSet) { setActivityLifecycleCallbacks(applicationContext); } if (context instanceof Activity) { callMethodShortcut((Activity) context); } } }
Shortbread { @TargetApi(25) public static void create(@NonNull Context context) { if (Build.VERSION.SDK_INT < 25) { return; } if (generated == null) { try { generated = Class.forName("shortbread.ShortbreadGenerated"); createShortcuts = generated.getMethod("createShortcuts", Context.class); callMethodShortcut = generated.getMethod("callMethodShortcut", Activity.class); } catch (ClassNotFoundException e) { Log.i(Shortbread.class.getSimpleName(), "No shortcuts found"); } catch (NoSuchMethodException e) { e.printStackTrace(); } } Context applicationContext = context.getApplicationContext(); if (!shortcutsSet) { setShortcuts(applicationContext); } if (!activityLifecycleCallbacksSet) { setActivityLifecycleCallbacks(applicationContext); } if (context instanceof Activity) { callMethodShortcut((Activity) context); } } private  Shortbread(); }
Shortbread { @TargetApi(25) public static void create(@NonNull Context context) { if (Build.VERSION.SDK_INT < 25) { return; } if (generated == null) { try { generated = Class.forName("shortbread.ShortbreadGenerated"); createShortcuts = generated.getMethod("createShortcuts", Context.class); callMethodShortcut = generated.getMethod("callMethodShortcut", Activity.class); } catch (ClassNotFoundException e) { Log.i(Shortbread.class.getSimpleName(), "No shortcuts found"); } catch (NoSuchMethodException e) { e.printStackTrace(); } } Context applicationContext = context.getApplicationContext(); if (!shortcutsSet) { setShortcuts(applicationContext); } if (!activityLifecycleCallbacksSet) { setActivityLifecycleCallbacks(applicationContext); } if (context instanceof Activity) { callMethodShortcut((Activity) context); } } private  Shortbread(); @TargetApi(25) static void create(@NonNull Context context); }
Shortbread { @TargetApi(25) public static void create(@NonNull Context context) { if (Build.VERSION.SDK_INT < 25) { return; } if (generated == null) { try { generated = Class.forName("shortbread.ShortbreadGenerated"); createShortcuts = generated.getMethod("createShortcuts", Context.class); callMethodShortcut = generated.getMethod("callMethodShortcut", Activity.class); } catch (ClassNotFoundException e) { Log.i(Shortbread.class.getSimpleName(), "No shortcuts found"); } catch (NoSuchMethodException e) { e.printStackTrace(); } } Context applicationContext = context.getApplicationContext(); if (!shortcutsSet) { setShortcuts(applicationContext); } if (!activityLifecycleCallbacksSet) { setActivityLifecycleCallbacks(applicationContext); } if (context instanceof Activity) { callMethodShortcut((Activity) context); } } private  Shortbread(); @TargetApi(25) static void create(@NonNull Context context);  }