Thanks to @Fllo. The problem was that I forgot to call onSaveInstanceState()
of parent activity.
@Override
protected void onSaveInstanceState(Bundle outState)
{
//Added this and the problem was solved
super.onSaveInstanceState(outState);
...
}