Android – Camera preview is sideways

This issue appeared to start out as a bug with certain hardware see here but can be overcome by using the call to mCamera.setDisplayOrientation(degrees) available in API 8. So this is how I implement it: public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { if (isPreviewRunning) { mCamera.stopPreview(); } Parameters parameters = mCamera.getParameters(); … Read more

How to lock orientation of one view controller to portrait mode only in Swift

Things can get quite messy when you have a complicated view hierarchy, like having multiple navigation controllers and/or tab view controllers. This implementation puts it on the individual view controllers to set when they would like to lock orientations, instead of relying on the App Delegate to find them by iterating through subviews. Swift 3, … Read more

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

Import package:flutter/services.dart, then Put the SystemChrome.setPreferredOrientations inside the Widget build() method. Example: class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); return new MaterialApp(…); } } Update This solution mightn’t work for some IOS devices as mentioned in the updated flutter documentation on Oct 2019. They Advise to fixed the … Read more

Force “portrait” orientation mode

Don’t apply the orientation to the application element, instead you should apply the attribute to the activity element, and you must also set configChanges as noted below. Example: <activity android:screenOrientation=”portrait” android:configChanges=”orientation|keyboardHidden”> </activity> This is applied in the manifest file AndroidManifest.xml.