How to handle screen rotation on Android
Changing a phone’s orientation is more than turning the handset sideways. Android uses motion sensors to decide when the display should move between portrait and landscape, but individual apps can impose their own rules. That difference explains why a browser may rotate while a camera or video player stays fixed, and it matters for commuters using crowded trains in Sydney and Melbourne.
For developers, the work extends beyond an on-screen toggle. A dependable implementation respects the user’s preference, adapts layouts to different shapes and retains entered information or playback position after a turn. Together, these steps cover device controls, app configuration, saved state, physical testing and common faults without relying on random resets.
Check the controls on your device
Android’s rotation sensor interprets gravity and device posture, then compares that result with the hardware’s natural orientation. Most phones treat portrait as natural, while many tablets use landscape, which affects whether an upside-down display also turns. Foldables add another variable because unfolding or changing posture can alter the available window size.
On most Android phones, pull down Quick Settings and look for Auto-rotate, Rotation or Rotate screen. If the tile is hidden, swipe through the full panel or edit the available tiles. The equivalent setting is usually under Settings > Display > Display orientation or Rotation, although labels differ between Google, Samsung and other versions.
Check the phone’s actual behaviour before changing app code. Turn the handset slowly through quarter turns, confirm that the display follows, and try the opposite direction. A case, a shelf or a desk can obstruct the sensor, and some tablet layouts respond differently from a conventional handset.
Enable or disable automatic rotation
Automatic rotation works as a system-wide preference. With it enabled, compatible activities follow the device posture; with it disabled, the current orientation normally remains fixed. Some home-screen apps also offer a portrait-only option, which restricts how apps open rather than acting as the same control.
Specific apps may provide a manual rotate button, particularly media players and camera interfaces. Activating that control usually affects the current activity, not the entire phone. This is useful for watching a video sideways while keeping the rest of the system in portrait.
Choose the behaviour that matches the task. Landscape can suit a map or a hands-free video, while a fixed display may be easier to read in strong Australian sunlight or while standing on a packed train. In a right-hand-drive car, check that a mounted phone remains readable without obstructing the driver’s view or required controls.
Respect orientation settings in your app
For a general-purpose Android activity, the best default is to omit a forced orientation from the manifest. With no restrictive android:screenOrientation attribute, the activity can follow the system policy and the user’s auto-rotate preference. This avoids trapping users in a layout that was designed only for portrait.
Use android:screenOrientation="sensorLandscape" when a particular workflow genuinely belongs sideways, such as a specialised scanning activity. A portrait-only camera or document scanner can also be deliberate, but it should be an intentional product decision rather than a way to avoid making a landscape layout.
Do not add android:configChanges="orientation|screenSize" merely to stop the activity being recreated. Handling those changes means your code must update spacing, resources and view state itself. If you declare them, implement the matching configuration logic carefully; otherwise, let Android recreate the activity and use the supported state-saving mechanisms.
Preserve state while the screen turns
Recreation is useful because Android can load the correct layout for the new space. Provide a layout-land alternative when the landscape arrangement needs different structure, and use flexible constraints, scrollable containers and appropriate dimensions instead of fixed widths. On tablets and foldables, confirm the interface also works with split-screen windows rather than assuming a full landscape canvas.
Save meaningful state before the turn. A ViewModel can retain data across configuration changes, onSaveInstanceState can preserve lightweight values, and Jetpack Compose code can use rememberSaveable for suitable inputs. These mechanisms have different lifetimes, so saved text, a selected tab, scroll position, a timer and media playback should each be tested rather than assumed safe.
Test on the phones sold in Australia
Australian buyers can choose from entry-level Android Go phones through to premium Samsung Galaxy, Google Pixel and foldable models at JB Hi-Fi, Officeworks and Amazon Australia. That range makes physical testing valuable: budget hardware may have fewer sensors, less memory or different firmware policies, while a high-end handset can conceal layout problems through a more capable processor.
With developer tools available, an emulator is useful for quick layout checks. Its virtual-sensor controls can simulate different device postures without moving a real handset. On a connected device, adb shell settings put system accelerometer_rotation 1 enables automatic rotation and replacing 1 with 0 disables it; adb shell settings get system accelerometer_rotation reports the current setting. These commands normally do not require root access.
Test the same journey in both directions, including form entry, scrolling, media playback and an interrupted network request. If a second reference helps while comparing devices, the Android rotation guidance provides another place to check the device-side basics. Keep the handset’s model, Android version and app version with any fault report.
Troubleshoot rotation that stays stuck
Rotation that never changes usually belongs to one of three layers. First, check the Quick Settings toggle, reopen the app and make sure a case is not covering the sensor. Then inspect the app for its own orientation lock or manifest restriction. Finally, consider firmware, an outdated app, a managed device policy or a kiosk task that may deliberately prevent rotation.
If the handset turns but the screen does not, recreate the app and review its layout resources and configuration callbacks. An emulator can also appear faulty when only the preview has been resized rather than the virtual orientation sensor being updated. Update the system and app after checking their release notes, but avoid a factory reset until simpler causes have been ruled out and your data is backed up.
Put the finished experience into practice
A reliable approach is straightforward: honour the system preference, reserve fixed orientation for clearly specialised activities, keep essential state across recreation and design every layout for the space it receives. For everyday use, a visible rotation control should have an obvious effect and return control to the automatic setting without leaving the device in an inconsistent state.
Before shipping, check Australian date and time formats, text size, keyboard panels and display cutouts in both orientations. Include a device with large fonts or a small screen in the test set, and make sure navigation remains reachable when a keyboard occupies much of the available height.
Run a two-minute check now: enable auto-rotate, open your most-used app, and turn the handset through 90 and 180 degrees. Confirm that text stays readable, controls remain reachable and your place in a form or video is preserved. If the app fails, note the device model, Android version, app version and whether any in-app orientation lock is active before making a change.