Android Fragment and getWindow()
Example from Activity
getWindow().setStatusBarColor(getResources().getColor(R.color.black));
Example from Fragment
requireActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.black));
you can use getActivity().getWindow()
this getActivity()
will Return the Activity this fragment is currently associated with.