fixed a bug where fast switching between activities could cause the active activity to disappear