Assume my application contains two activity, A and B.
Both are limited to portrait in AndroidManifest.
Activity A started Activity B.
In Activity B, there is a button, which calls
dispatchKeyEvent(new KeyEvent (KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
dispatchKeyEvent(new KeyEvent (KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK));
It happens because you have changed the orientation at some stage when the application has started, imo.
On orientation change the activity is destroyed then recreated. To avoid it handle the orientation.
Handle the orientation change by yourself by adding the following line in the manifest file , under activity.
<activity android:name=".Activity_name" android:configChanges="orientation|keyboardHidden|screenSize"