Because you don’t put checks for NullPointerException
((AppCompatActivity) getActivity()).getSupportActionBar() gives actionbar object
but you are calling directly by
((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false)
that is why system gives warning for NullPointerException.
if((getActivity()) != null) {
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false);
}
}
Put above code. Your warning will remove.
1
solved Suppress NPE Warning for getSupportActionBar() when called inside Fragments [duplicate]