Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION_CODES.M; public class Main { public static int getColor(Context context, int colorResId) { int color; if (SDK_INT >= M) { color = context.getColor(colorResId); } else { color = context.getResources().getColor(colorResId); } return color; } }