@Test public void testGetColor() throws Throwable { assertEquals("Unthemed color load", 0xFFFF8090, ContextCompat.getColor(mContext, R.color.text_color)); if (Build.VERSION.SDK_INT >= 23) { assertEquals("Themed yellow color load", ContextCompat.getColor(mContext, R.color.simple_themed_selector), 0xFFF0B000); } }
@ColorInt public static int getColor(@NonNull Context context, @ColorRes int id) { if (Build.VERSION.SDK_INT >= 23) { return context.getColor(id); } else { return context.getResources().getColor(id); } }
ContextCompat { @ColorInt public static int getColor(@NonNull Context context, @ColorRes int id) { if (Build.VERSION.SDK_INT >= 23) { return context.getColor(id); } else { return context.getResources().getColor(id); } } }
ContextCompat { @ColorInt public static int getColor(@NonNull Context context, @ColorRes int id) { if (Build.VERSION.SDK_INT >= 23) { return context.getColor(id); } else { return context.getResources().getColor(id); } } protected  ContextCompat(); }
ContextCompat { @ColorInt public static int getColor(@NonNull Context context, @ColorRes int id) { if (Build.VERSION.SDK_INT >= 23) { return context.getColor(id); } else { return context.getResources().getColor(id); } } protected  ContextCompat(); static boolean startActivities(@NonNull Context context, @NonNull Intent[] intents); static boolean startActivities(@NonNull Context context, @NonNull Intent[] intents,
            @Nullable Bundle options); static void startActivity(@NonNull Context context, @NonNull Intent intent,
            @Nullable Bundle options); @Nullable static File getDataDir(@NonNull Context context); @NonNull static File[] getObbDirs(@NonNull Context context); @NonNull static File[] getExternalFilesDirs(@NonNull Context context, @Nullable String type); @NonNull static File[] getExternalCacheDirs(@NonNull Context context); @Nullable static Drawable getDrawable(@NonNull Context context, @DrawableRes int id); @Nullable static ColorStateList getColorStateList(@NonNull Context context,
            @ColorRes int id); @ColorInt static int getColor(@NonNull Context context, @ColorRes int id); static int checkSelfPermission(@NonNull Context context, @NonNull String permission); @Nullable static File getNoBackupFilesDir(@NonNull Context context); static File getCodeCacheDir(@NonNull Context context); @Nullable static Context createDeviceProtectedStorageContext(@NonNull Context context); static boolean isDeviceProtectedStorage(@NonNull Context context); static void startForegroundService(@NonNull Context context, @NonNull Intent intent); @SuppressWarnings("unchecked") @Nullable static T getSystemService(@NonNull Context context, @NonNull Class<T> serviceClass); @Nullable static String getSystemServiceName(@NonNull Context context,
            @NonNull Class<?> serviceClass); }
ContextCompat { @ColorInt public static int getColor(@NonNull Context context, @ColorRes int id) { if (Build.VERSION.SDK_INT >= 23) { return context.getColor(id); } else { return context.getResources().getColor(id); } } protected  ContextCompat(); static boolean startActivities(@NonNull Context context, @NonNull Intent[] intents); static boolean startActivities(@NonNull Context context, @NonNull Intent[] intents,
            @Nullable Bundle options); static void startActivity(@NonNull Context context, @NonNull Intent intent,
            @Nullable Bundle options); @Nullable static File getDataDir(@NonNull Context context); @NonNull static File[] getObbDirs(@NonNull Context context); @NonNull static File[] getExternalFilesDirs(@NonNull Context context, @Nullable String type); @NonNull static File[] getExternalCacheDirs(@NonNull Context context); @Nullable static Drawable getDrawable(@NonNull Context context, @DrawableRes int id); @Nullable static ColorStateList getColorStateList(@NonNull Context context,
            @ColorRes int id); @ColorInt static int getColor(@NonNull Context context, @ColorRes int id); static int checkSelfPermission(@NonNull Context context, @NonNull String permission); @Nullable static File getNoBackupFilesDir(@NonNull Context context); static File getCodeCacheDir(@NonNull Context context); @Nullable static Context createDeviceProtectedStorageContext(@NonNull Context context); static boolean isDeviceProtectedStorage(@NonNull Context context); static void startForegroundService(@NonNull Context context, @NonNull Intent intent); @SuppressWarnings("unchecked") @Nullable static T getSystemService(@NonNull Context context, @NonNull Class<T> serviceClass); @Nullable static String getSystemServiceName(@NonNull Context context,
            @NonNull Class<?> serviceClass);  }