Get phone orientation but fix screen orientation to portrait

Here is a multi-purpose class for easily managing screen orientation changes: public class OrientationManager extends OrientationEventListener { public enum ScreenOrientation { REVERSED_LANDSCAPE, LANDSCAPE, PORTRAIT, REVERSED_PORTRAIT } public ScreenOrientation screenOrientation; private OrientationListener listener; public OrientationManager(Context context, int rate, OrientationListener listener) { super(context, rate); setListener(listener); } public OrientationManager(Context context, int rate) { super(context, rate); } public OrientationManager(Context … Read more

How to stop changing the orientation when a progress bar is spinning in android

This is happening because when screen orientation rotates the Activity gets re-started. In this case you can add configChanges attribute in your tag in the AndroidManifest file to stop the re-creation of the Activity. <activity android:name=”.Activity_name” android:configChanges=”orientation|keyboardHidden”> By, this your orientation can change will the progress bar is working and also it won’t stop though … Read more

Will $(window).resize() fire on orientation change?

Some devices/browsers do, some not. You need to decide your supported browsers and devices. If you want to be on secure side you should use the resize event and get/check the sizes inside in it; if you know your desired devices go with a simple orientation change: Easy solution: // Listen for orientation changes window.addEventListener(“orientationchange”, … Read more

iphone/ipad orientation handling

I do this with two simple methods in my view controller: – (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [self adjustViewsForOrientation:toInterfaceOrientation]; } – (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation { if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { titleImageView.center = CGPointMake(235.0f, 42.0f); subtitleImageView.center = CGPointMake(355.0f, 70.0f); … } else if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { titleImageView.center = CGPointMake(160.0f, … Read more

PhoneGap – Forcing Landscape orientation

Have you tried this? android:screenOrientation=”portrait” Inside the AndroidManifest.xml file, where you have declared your activity, just add the above line. For example: <activity android:name=”.Activity.SplashScreenActivity” android:label=”@string/app_name” android:screenOrientation=”portrait”> <intent-filter> <action android:name=”android.intent.action.MAIN” /> <category android:name=”android.intent.category.LAUNCHER” /> </intent-filter> </activity>

I want my android application to be only run in portrait mode?

In the manifest, set this for all your activities: <activity android:name=”.YourActivity” android:configChanges=”orientation” android:screenOrientation=”portrait”/> Let me explain: With android:configChanges=”orientation” you tell Android that you will be responsible of the changes of orientation. android:screenOrientation=”portrait” you set the default orientation mode.