When i changed screen from portrait mode to land scape mode then automatically came out from my application.(same as landscape to portrait also)can any one tell me the solution for this..
this is my code for orientation,
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
Toast.makeText(MyAlphabetsActivity.this, "ORIENTATION_PORTRAIT",
Toast.LENGTH_SHORT).show();
setContentView(R.layout.portrait_main);
System.out.println("int-----1--");
} else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
setContentView(R.layout.landscape_main);
Toast.makeText(MyAlphabetsActivity.this, "ORIENTATION_LANDSCAPE",
Toast.LENGTH_SHORT).show();
System.out.println("int-----2--");
}
when change portrait to landscape control entered into else if() and display Toast massage also…….
If you have same layout in
portraitas well as in thelandscapemode then its better to stop the re-creation of Activity on rotation change by addingattribute in your activity tag in the Manifest file.