Android application terminate when the layout goes to landscape
<p>I am new to this site.I am doing android application for my practice. I have design layout that is vertical.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/wallpaper"&gt;
    &lt;TableLayout android:layout_height="wrap_content" android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_marginBottom="50dp" android:layout_weight="1"&gt;
        &lt;TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;
            &lt;TextView android:text="Call Lost" android:layout_marginLeft="100dp" android:textColor="@color/darkGreen" android:layout_marginBottom="20dp"  android:textStyle="bold" android:textSize="20dp" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/thcall"&gt;&lt;/TextView&gt;
        &lt;/TableRow&gt;


        &lt;TableRow android:id="@+id/tableRow1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dp"&gt;
            &lt;TextView android:id="@+id/calostRetailer" android:layout_height="wrap_content" android:text="Retiler Name :" android:layout_weight="0.8" android:layout_width="0dp" &gt;&lt;/TextView&gt;
            &lt;TextView android:text="Retiler Name" android:layout_height="wrap_content" android:id="@+id/txtcalostRetailer" android:layout_weight="0.8" android:layout_width="55dp" &gt;&lt;/TextView&gt;
        &lt;/TableRow&gt;

        &lt;TableRow android:id="@+id/tableRow2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dp"&gt;
            &lt;TextView android:text="Call Lost Reason" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.4" android:id="@+id/txtcalostRetailer" &gt;&lt;/TextView&gt;
            &lt;Spinner android:layout_height="wrap_content" android:id="@+id/cal_lost_reason" android:layout_weight="0.8" android:layout_width="150dp"&gt;&lt;/Spinner&gt;
        &lt;/TableRow&gt;


         &lt;TableRow android:id="@+id/tableRow3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dp"&gt;
             &lt;CheckBox android:text="Cancael" android:id="@+id/chkCallLost" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/CheckBox&gt;
        &lt;/TableRow&gt;

    &lt;/TableLayout&gt;


    &lt;LinearLayout android:id="@+id/headerInDis"
            android:background="#000000"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"&gt;

            &lt;Button android:layout_width="wrap_content" 
                    android:text="Cancel" 
                    android:background="@drawable/btn_yellow"
                    android:layout_height="wrap_content" 
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="235dp"
                    android:id="@+id/callLostCancel" 
                    android:textColor="#FFFFFF"
                    &gt;
           &lt;/Button&gt;

            &lt;Button android:layout_width="wrap_content" 
                    android:text="Ok" 
                    android:background="@drawable/btn_yellow"
                    android:layout_height="wrap_content" 
                    android:textColor="#FFFFFF"
                    android:id="@+id/callLostDOk" 
                    &gt;
           &lt;/Button&gt;
        &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>In manifest file i declared like</p>

<pre><code>      &lt;application  android:configChanges="orientation|keyboardHidden" android:label="Vertusel"  android:icon="@drawable/virtusel64" android:allowClearUserData="true" android:debuggable="true" android:enabled="true" &gt;
        &lt;activity android:name=".AndroidAppXontTabActivity" &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=".sales.CallLostActivity" android:configChanges="orientation|keyboardHidden"&gt;&lt;/activity&gt;
    .....
</code></pre>

<p>This is my activity class:</p>

<pre><code>    public class CallLostActivity extends Activity{
    private String retailerName = "";
    private String retailerCode = "";
    private HashMap&lt;String,CallLostReason&gt; callList = new  HashMap&lt;String,CallLostReason&gt;();
    Spinner cal_lost_reason;
    String selectedCallReason;
    SharedPreferences myRoutes;
    String visitNumber ="0";
//  private boolean isDefault = false;
    private String strBusinessUnit ="";
    private String strExecutive = "";

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View v = LayoutInflater.from(getParent()).inflate(R.layout.calllost, null);
        setContentView(v);
        getParent().getParent().setTitle("Call Lost");
        Bundle bundle = this.getIntent().getExtras();
        retailerName = bundle.getString("RetailerName");
        retailerCode = bundle.getString("RetailerCode");

        TextView txtcalostRetailer = (TextView)findViewById(R.id.txtcalostRetailer);
        txtcalostRetailer.setText(retailerName);

         //getting logged users stored values from file - using SharedPreferences
        SharedPreferences myPrefs = this.getSharedPreferences("myLogedPrefs",MODE_WORLD_READABLE);
        strBusinessUnit = myPrefs.getString("BusinessUnit", "");
        strExecutive = myPrefs.getString("Executive", "");

        myRoutes = this.getSharedPreferences("myDefalutRoute",MODE_PRIVATE);
        visitNumber = myRoutes.getString("visitnumber", "-1");
    //  isDefault = myRoutes.getBoolean("isDefault", false);

        callList = getAllCallLoast();
        ArrayList&lt;String&gt; callLostList = new ArrayList&lt;String&gt;();
        callLostList.add("--Select--");
        for (Map.Entry&lt;String, CallLostReason&gt; entry : callList.entrySet()) {
                // String key = entry.getKey();
                CallLostReason myCallLostReason = entry.getValue();
                callLostList.add(myCallLostReason.getDescription());
        }

        cal_lost_reason = (Spinner) findViewById(R.id.cal_lost_reason);
        ArrayAdapter&lt;String&gt;  reasonAdapter = new ArrayAdapter&lt;String&gt;(v.getContext(),android.R.layout.simple_spinner_item, callLostList);
        reasonAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
        cal_lost_reason.setAdapter(reasonAdapter);
        cal_lost_reason.setOnItemSelectedListener(new OnItemSelectedListener() {

            public void onItemSelected(AdapterView&lt;?&gt; parent, View view,int arg2, long arg3) {
                selectedCallReason = parent.getSelectedItem().toString();
            }

            public void onNothingSelected(AdapterView&lt;?&gt; arg0) {

            }
        });

        CheckBox chkCallLost = (CheckBox)findViewById(R.id.chkCallLost);
        chkCallLost.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
                if(arg0.isChecked()){   
                    AlertDialog.Builder routeDefaultQue = new AlertDialog.Builder(SalesActivityGroup.group.getParent());
                    routeDefaultQue.setMessage("Are you going to do the Sale Lost? ");
                    routeDefaultQue.setCancelable(false);
                    routeDefaultQue.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                        boolean status = saveCalLost("2");
                        } 

                    });
                    routeDefaultQue.setNegativeButton("No", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
                    routeDefaultQue.setTitle("Sale Lost...");
                    routeDefaultQue.show();
                }else {
                    AlertDialog.Builder routeDefaultQue = new AlertDialog.Builder(SalesActivityGroup.group.getParent());
                    routeDefaultQue.setMessage("Are you going to do the Sale Lost? ");
                    routeDefaultQue.setCancelable(false);
                    routeDefaultQue.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                        boolean status = saveCalLost("3");
                        } 

                    });
                    routeDefaultQue.setNegativeButton("No", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
                    routeDefaultQue.setTitle("Sale Lost...");
                    routeDefaultQue.show();
                }
            }
        });
        Button callLostDOk = (Button)findViewById(R.id.callLostDOk);
        callLostDOk.setOnClickListener(new OnClickListener() {
               public void onClick(View v) {
                    AlertDialog.Builder routeDefaultQue = new AlertDialog.Builder(SalesActivityGroup.group.getParent());
                    routeDefaultQue.setMessage("Are you going to do the Sale Lost? ");
                    routeDefaultQue.setCancelable(false);
                    routeDefaultQue.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                        boolean status = saveCalLost("3");
                        } 

                    });
                    routeDefaultQue.setNegativeButton("No", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
                    routeDefaultQue.setTitle("Sale Lost...");
                    routeDefaultQue.show();

               }
        });

        Button callLostCancel = (Button)findViewById(R.id.callLostCancel);
        callLostCancel.setOnClickListener(new OnClickListener() {
               public void onClick(View v) {
                    Intent i = new Intent(getBaseContext(), RetailerOptionActivity.class);
                     Bundle bundle = new Bundle(); 
                         bundle.putString("Activity", "CallLostActivity");
                         bundle.putString("RetailerName", retailerName);
                         bundle.putString("RetailerCode", retailerCode);
                         i.putExtras(bundle);
                    View vi = SalesActivityGroup.group.getLocalActivityManager().startActivity("CallLostActivity", i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
                    SalesActivityGroup.group.replaceView(vi);
               }
        });


    }


    public boolean saveCalLost(String statusValue){
        DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this);
        dbAdapter.openDataBase();
        boolean visitStatus = false;
        Date date = new Date();
        DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
         String strDate = formatter.format(date);
        String sql = "SELECT VisitNumber,VisitSequence,SeletcedDefaultRouteRetailer FROM WMVisitDetail  WHERE VisitNumber= ? AND ExecutiveCode=?";
        String[]d = new String[]{visitNumber,strExecutive};
        ArrayList&lt;?&gt; stringList = dbAdapter.selectRecordsFromDBList(sql, d);

        if(stringList.size() &gt; 0){
            visitStatus = true;
        }

        ContentValues initialValues = new ContentValues();
        initialValues.put("Status",statusValue);

        System.out.println("---visitStatus---" +visitStatus);
        if (visitStatus) {
            String whereCon = "BusinessUnit ='"+strBusinessUnit+"' AND VisitNumber ='"+visitNumber+"' AND ExecutiveCode ='"+strExecutive+"' AND RetailerCode ='"+retailerCode+ "' AND BusinessUnit='"+strBusinessUnit+"'";
            long n = dbAdapter.updateRecordsInDB("WMVisitDetail", initialValues, whereCon, null);
            System.out.println("----WMVisitDetail---" + n);
            //WMRetailer update
            ContentValues retailerValues = new ContentValues();
            retailerValues.put("isSaveSales",1);
            retailerValues.put("UpdateOn",strDate);
            String strWhereField = " BusinessUnit = '"+ strBusinessUnit+"' AND SalesExecutiveCode ='" +strExecutive + "' AND RetailerCode='"+retailerCode+"'";
            long retailerUpdate = dbAdapter.updateRecordsInDB("WMRetailer", retailerValues, strWhereField, null);
            System.out.println("---retailerUpdate--" + retailerUpdate);
        } else{
            Toast.makeText(SalesActivityGroup.group.getParent(),"You have already made invoice today.You can't make call Loast " ,Toast.LENGTH_SHORT).show();
        }

        dbAdapter.close();
        return visitStatus;
    }

    public HashMap&lt;String,CallLostReason&gt; getAllCallLoast(){
        DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this);
        dbAdapter.openDataBase();

        String  query = "SELECT CallLostReasonCode,Description ,Status FROM WMCallLostReason WHERE Status = '1' ";
        ArrayList&lt;?&gt; stringList = dbAdapter.selectRecordsFromDBList(query, null);

        dbAdapter.close();
        HashMap&lt;String,CallLostReason&gt; wmCallLoast = new HashMap&lt;String,CallLostReason&gt;();
        for (int i = 0; i &lt; stringList.size(); i++) {

            ArrayList&lt;?&gt; arrayList = (ArrayList&lt;?&gt;) stringList.get(i);
            ArrayList&lt;?&gt; list = arrayList;
            CallLostReason lostReason = new CallLostReason();
            lostReason.setDescription((String) list.get(1));
            lostReason.setCallLostReasonCode((String) list.get(0));
            lostReason.setStatus((String) list.get(2));
            wmCallLoast.put((String) list.get(1),lostReason);
        }
        return wmCallLoast;
    }

}
</code></pre>

<p>Likewise i have.</p>

<p>My question is when the user change the phone to landscape its terminate the application.</p>

<p>Please any friends tell me what is wrong in my code?</p>
