Generally for terminating the Thread , the following code is used:
new Thread((new Runnable() { @Override public void run() { ........ if (getActivity == null) return; } } ).start();
In this code, Checking the getActivity is done only for one time. Is there any code, so that whenever getActivity becomes null, return is called on the thread from where it is called.