Android orentation change weird problem
<p>I have some really strange issue when changing orientation of my emulator. In my app I call activity named "Setting" from my main activity when an image button it clicked. here is the code for that:</p>

<pre><code>final ImageButton stbtn = (ImageButton) findViewById(R.id.stbtn);  
        stbtn.setOnClickListener(new OnClickListener() {  
             public void onClick(View v) {  
                Intent stopn = new Intent(MyApp.this, Settings.class);
                startActivity(stopn);
            }  
        });
</code></pre>

<p>Here is how I close Settings activity:</p>

<pre><code>@Override
    public void onBackPressed() {
        // do something on back.
        finish();       
        return;
    }

@Override
    protected void onPause(){

       super.onPause();   
       saveSettings();

    }
</code></pre>

<p>and in my main activity I have surface view that update screen every second. I go to Settings screen to change settings and press back button to close it and then it goes to the main activity screen this works fine. Problem now is that when I change orientation when the app is on main screen it opens Settings activity back. Is it because I haven't closed activity properl or is it something else? Can anyone please help me with this? Thanks</p>

<p>Edit:</p>

<p>Here is the code for mainfest and activities</p>

<pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.myapp"
      android:versionCode="1"
      android:versionName="1.0"&gt;
    &lt;application android:name=".myappApp" android:icon="@drawable/icon" android:label="@string/app_name"&gt;
        &lt;activity android:name=".MyAlarm"
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                  android:configChanges="orientation"
                  android:label="@string/app_name"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
        &lt;activity android:name=".Settings" android:label="@string/app_name"&gt;
        &lt;/activity&gt;
    &lt;/application&gt;
&lt;/manifest&gt; 
</code></pre>

<p>Main activity code:</p>

<pre><code>public class MyAlarm extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        getClockSettings();
        HandView hndView = (HandView) findViewById(R.id.hndView);
        clkapp = ((myappApp)getApplicationContext());
        hndView.setStyle(clkapp.getClkStyle(), clkapp.isAnalog());
        final ImageButton alrbtn = (ImageButton) findViewById(R.id.alrbtn);  
        alrbtn.setOnClickListener(new OnClickListener() {  
             public void onClick(View v) {  

             }  
        });  
        final ImageButton stbtn = (ImageButton) findViewById(R.id.stbtn);  
        stbtn.setOnClickListener(new OnClickListener() {  
             public void onClick(View v) {  
                Intent stopn = new Intent(MyAlarm.this, Settings.class);
                //stopn.setClassName("com.example.myapp", "com.example.myapp.Settings");
                startActivity(stopn);
            }  
        });

        stbtn.setOnTouchListener(new OnTouchListener() {  
           @Override
            public boolean onTouch(View v, MotionEvent event) {
                v.requestFocusFromTouch();
                Intent stopn = new Intent(MyAlarm.this, Settings.class);
                   //stopn.setClassName("com.example.myapp", "com.example.myapp.Settings");
                startActivity(stopn);
                return true;
            }  
       });        


    }


    protected void getClockSettings() {
        //getting setting from preferences
    clkSettings = getSharedPreferences(PREFS_NAME, 0);      
        if (clkapp == null) clkapp = ((myappApp)getApplicationContext());
        clkapp.clkSettings = clkSettings;
        if (clkSettings == null) {
            /*clk24 = false;
            clkAnalogue = true;
            dSec = true;
            _clockStyle = "Black";*/
            clkapp.set24Hr(false);
            clkapp.setAnalog(true);
            clkapp.setDisplaySec(true);
            clkapp.setClkStyle("Black");
        }
        else {
            /*clk24 = clkSettings.getBoolean("24Hr", false);
            dSec = clkSettings.getBoolean("dSecond", true);
            clkAnalogue = clkSettings.getBoolean("ClkAnalogue", true);
            if (clkAnalogue) _clockStyle = clkSettings.getString("ClkAnalogStyle", "Black");
            else _clockStyle = clkSettings.getString("ClkAnalogStyle", "DigitalBlack");*/
            clkapp.set24Hr(clkSettings.getBoolean("24Hr", false));
            clkapp.setAnalog(clkSettings.getBoolean("ClkAnalogue", true));
            clkapp.setDisplaySec(clkSettings.getBoolean("dSecond", true));
            if (clkapp.isAnalog()) clkapp.setClkStyle(clkSettings.getString("ClkAnalogStyle", "Black"));
            else clkapp.setClkStyle(clkSettings.getString("ClkAnalogStyle", "DigitalBlack"));
        }
    }

    public void onConfigurationChanged(Configuration newConfig) {
          //ignore orientation change
          super.onConfigurationChanged(newConfig);
    }
}
</code></pre>

<p>Settings activity:</p>

<pre><code>public class Settings extends Activity {

    //Your member variable declaration here
    private RadioButton crbon;
    private RadioButton blue;
    private RadioButton bbl;
    private RadioButton crbdig;
    private RadioButton grndig;
    private ToggleButton tb24;
    private ToggleButton tbsec;

    // Called when the activity is first created.
    @Override
    public void onCreate(Bundle savedInstanceState) {
    //Your code here
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings); 
        myappApp clkapp = ((myappApp)getApplicationContext());
        //RadioGroup rbgrp = (RadioGroup)findViewById(R.id.rbfacegrp);

        crbon=(RadioButton)findViewById(R.id.radio_carbon);
        blue=(RadioButton)findViewById(R.id.radio_blue);
        bbl=(RadioButton)findViewById(R.id.radio_bbl);
        crbdig=(RadioButton)findViewById(R.id.radio_crbdig);
        grndig=(RadioButton)findViewById(R.id.radio_grndig);
        tb24=(ToggleButton)findViewById(R.id.tbhr);
        tbsec=(ToggleButton)findViewById(R.id.tbsec);
        if(clkapp.getClkStyle().toLowerCase().equals("black")) {
            crbon.setChecked(true);
        }
        else if(clkapp.getClkStyle().toLowerCase().equals("blue")) {
            blue.setChecked(true);
        }
        else if(clkapp.getClkStyle().toLowerCase().equals("bubble")) {
            bbl.setChecked(true);
        }
        else if(clkapp.getClkStyle().toLowerCase().equals("digitalblack")) {
            crbdig.setChecked(true);
        }
        else if(clkapp.getClkStyle().toLowerCase().equals("digitalgreen")) {
            grndig.setChecked(true);
        }
        tb24.setChecked(clkapp.is24Hr());
        tbsec.setChecked(clkapp.isDisplaySec());


    }

    @Override
    protected void onPause(){       
       super.onPause();   
       saveSettings();
        //this.finish();       
    }


    protected void saveSettings() {
        boolean clkAna = true;
        myappApp clkapp = ((myappApp)getApplicationContext());
        SharedPreferences.Editor edt = clkapp.clkSettings.edit();
        edt.putBoolean("24Hr", tb24.isChecked());
        edt.putBoolean("dSecond", tbsec.isChecked());
        clkapp.set24Hr(tb24.isChecked());
        clkapp.setDisplaySec(tbsec.isChecked());
        if (crbon.isChecked()) {
            edt.putString("ClkAnalogStyle", "Black");
            clkapp.setClkStyle("Black");
            clkAna = true;
        }
        else if (blue.isChecked()) {
            edt.putString("ClkAnalogStyle", "Blue");
            clkapp.setClkStyle("Blue");
            clkAna = true;
        }
        else if (bbl.isChecked()) {
            edt.putString("ClkAnalogStyle", "Bubble");
            clkapp.setClkStyle("Bubble");
            clkAna = true;
        }           
        else if (crbdig.isChecked()) {
            edt.putString("ClkAnalogStyle", "DigitalBlack");
            clkapp.setClkStyle("DigitalBlack");
            clkAna = false;
        }
        else if (grndig.isChecked()) {
            edt.putString("ClkAnalogStyle", "DigitalGreen");
            clkapp.setClkStyle("DigitalGreen");
            clkAna = false;
        }
        clkapp.setAnalog(clkAna);
        edt.putBoolean("ClkAnalogue", clkAna);
        edt.commit();

    }



    @Override
    public void onBackPressed() {
        // do something on back.
        finish();       
        return;
    }

}
</code></pre>
