Fine-tuned logic to detect whether onStop is being called because of orientation change