How can I get the current screen orientation?

I just want to set some flags when my orientation is in landscape so that when the activity is recreated in onCreate() i can toggle between what to load in portrait vs. landscape. I already have a layout-land xml that is handling my layout. public void onConfigurationChanged(Configuration _newConfig) { if (_newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { this.loadURLData … Read more

Background task, progress dialog, orientation change – is there any 100% working solution?

I download some data from internet in background thread (I use AsyncTask) and display a progress dialog while downloading. Orientation changes, Activity is restarted and then my AsyncTask is completed – I want to dismiss the progess dialog and start a new Activity. But calling dismissDialog sometimes throws an exception (probably because the Activity was … Read more

Flutter: how to prevent device orientation changes and force portrait?

I would like to prevent my application from changing its orientation and force the layout to stick to “portrait”. In the main.dart, I put: void main(){ SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown ]); runApp(new MyApp()); } but when I use the Android Simulator rotate buttons, the layout “follows” the new device orientation… How could I solve this? Thanks … Read more

Force “portrait” orientation mode

I’m trying to force the “portrait” mode for my application because my application is absolutely not designed for the “landscape” mode. After reading some forums, I added these lines in my manifest file: <application android:debuggable=”true” android:icon=”@drawable/icon” android:label=”@string/app_name” android:screenOrientation=”portrait”> But it doesn’t work on my device (HTC Desire). It switches from “portrait” lo “landscape”, ignoring the … Read more

Check orientation on Android phone

How can I check if the Android phone is in Landscape or Portrait? 23 Answers 23 The current configuration, as used to determine which resources to retrieve, is available from the Resources’ Configuration object: getResources().getConfiguration().orientation; You can check for orientation by looking at its value: int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { // … Read more