public static int getAccentColorFromThemeIfAvailable(Context context) {
        TypedValue typedValue = new TypedValue();
        // First, try the android:colorAccent
        if (Build.VERSION.SDK_INT >= 21) {
            context.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
            return typedValue.data;
        }
        // Next, try colorAccent from support lib
        int colorAccentResId = context.getResources().getIdentifier("colorAccent", "attr", context.getPackageName());
        if (colorAccentResId != 0 && context.getTheme().resolveAttribute(colorAccentResId, typedValue, true)) {
            return typedValue.data;
        }
        // Return the value in mdtp_accent_color
        return ContextCompat.getColor(context, R.color.mdtp_accent_color);
    }
public static int getAccentColorFromThemeIfAvailable ( Context context ) { TypedValue typedValue = new TypedValue ( ) ; if ( Build . VERSION . SDK_INT >= 21 ) { context . getTheme ( ) . resolveAttribute ( android . R . attr . colorAccent , typedValue , true ) ; return typedValue . data ; } int colorAccentResId = context . getResources ( ) . getIdentifier ( "colorAccent" , "attr" , context . getPackageName ( ) ) ; if ( colorAccentResId != 0 && context . getTheme ( ) . resolveAttribute ( colorAccentResId , typedValue , true ) ) { return typedValue . data ; } return ContextCompat . getColor ( context , R . color . mdtp_accent_color ) ; }
Gets the colorAccent from the current context, if possible/available
@param context The context to use as reference for the color
@return the accent color of the current context