In my case the error occurred inside a Fragment
on this line:
Intent intent = new Intent(getActivity(), SecondaryActivity.class);
It happened when I double clicked on an item which triggered the code above so two SecondaryActivity.class
activities were launched at the same time, one on top of the other. I closed the top SecondaryActivity.class
activity by pressing back button which triggered a call to getActivity()
in the SecondaryActivity.class
which came to foreground. The call to getActivity()
returned null
.
It's some kind of weird Android bug so it usually should not happen.
You can block the clicks after the user clicked once.