I had a similar problem - in fact, I was getting NPE in the async task after the user destroyed the fragment. After examining the stack overflow problem, I made the following decision:
volatile boolean running; public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); running=true; ... } public void onDestroy() { super.onDestroy(); running=false; ... }
Then I periodically check "if running" in my asynchronous code. I have experienced this, and now I canโt โbreakโ my activity. This works great and has the advantage of being simpler than some of the solutions I've seen on SO.
IanB May 26 '13 at 16:44 2013-05-26 16:44
source share