Fix for #981 when the android framework returns NULL for getActivity()