fix a NPE when activity is detached