cara mendapatkan warna dari sumber daya android

In activity :
	ContextCompat.getColor(actvityname.this, R.color.your_color);
    
In fragment :
	ContextCompat.getColor(getActivity(), R.color.your_color);

Another method :
	getColor(R.color.snackBarAction)
android developer