I have an application in which a login screen shows up whenever an activity goes to onPause state. Generally, when screen orientation changes, the activity goes to onPause state
By default, Android will actually destroy and restart your activity on rotation. This causes onPause(), onStop(), onDestroy(), onCreate(), onStart(), onResume() to be called. The best way to avoid problems like this is to tell Android not to do that. In the manifest add android:configChange="orientation" to your Activity. It will prevent the destruction, and call a function on rotation instead. It will still correctly redraw your screen in almost all cases.