Android screen orientation

disable orientation change

<activity android:name=".MainActivity"
    android:screenOrientation="portrait"
    tools:ignore="LockedOrientationActivity">

Handling orientation state
Saving instance state

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putInt("ScoreKey", mScore);
    outState.putInt("IndexKey", mIndex);

}

Retrieving instance state

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (savedInstanceState != null){
        mScore = savedInstanceState.getInt("ScoreKey");
        mIndex = savedInstanceState.getInt("IndexKey");

    } else {
        mScore = 0;
        mIndex = 0;
    }