My Activity needs to monitor the orientation of the device. Now this works great with onConfigurationChanged()
, but I also need to know orientation when my Activity starts.
So how do find out the current orientation of the device in my onCreate()
, for instance?
I'm no expert but this works for me, in onCreate()
:
int display_mode = getResources().getConfiguration().orientation;
if (display_mode == Configuration.ORIENTATION_PORTRAIT) {
setContentView(R.layout.main);
} else {
setContentView(R.layout.main_land);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With