i am getting strange issue in my app. The main issue that i have asked here. issue is android:configChanges="keyboardHidden|orientation"
is not working in my code.
so i have found the solution to manage it by @Override onConfigurationChanged()
method in my code to manage orientation. but yet the issue is not solve properly.
Currently issue is that onConfigurationChanged()
is calling twice when we change orientation
landscape to portrait.
If we change phone portrait to landscape its changing and working but now when user move the phone landscape to portrait then onConfigurationChanged()
will call and return same orientation state & in second call it will return portrait.
Code :
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
Log.e("On Config Change", "LANDSCAPE");
Toast.makeText(getApplicationContext(), "L", Toast.LENGTH_LONG)
.show();
} else
{
Log.e("On Config Change", "PORTRAIT");
Toast.makeText(getApplicationContext(), "P", Toast.LENGTH_LONG)
.show();
}
}
Log
first mode its port mode , so change in land mode
02-28 12:10:06.274: E/On Config Change(540): LANDSCAPE
02-28 12:10:14.154: E/On Config Change(540): LANDSCAPE
// here after changed the land mode try to chage in port mode then its calling two times as you can see as per the log
02-28 12:10:14.593: E/On Config Change(540): PORTRAIT
02-28 12:11:39.524: E/On Config Change(540): LANDSCAPE
One more query with same question >>
It will kill the current activity when we change the orientation (at time of calling onConfigurationChanged
). so i have two layouts in different folder as per my previous question.So when i change the screen activity will remove all data.so how can i save that data to show user when user change the phone orientation in any case.