fixed crash at onResume/onPause