I have a fragment where I'll do the following:
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
}
});
Here I get for runOnUiThread
a warning may produce NullPointerException
.
The code works without problems.Android Studio suggests I change the code like this:
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
@Override
public void run() {
is that sensible ? is there any other/better way ?