Here is my analysis:

The function where this check was added is initConnection.  This is only called from initAccount.

initAccount is called from:

* setSpinnerState - called from onCreateView
* setupSpinners - called from onCreateView
* NewChatActivity.resolveIntent

In all three cases, the activity must have been constructed.  In the first two cases, the call is from onCreateView, which is later in the lifecycle than onAttach, so getActivity() cannot be null.  In the last case the call is from the activity itself.

I strongly recommend only engaging in defensive programming when there is a strong reason and we fully understand the mechanics of the situation.  Defensive programming tends to hide underlying issues.  For example, a few defensive statements caused us to spend quite a bit of time (at least a day) before we identified the static ChatPagerAdapter issue.  Once we removed the defensive checks, the issue was obvious because it failed fast with an exception.