Device Orientation (Fire Tablets)
Fire tablets allow for rotation of the display. To help ensure a good user experience, your app needs to account for changes in device orientation.
Landscape and Portrait Orientation
The following table shows orientation codes for the Fire tablets.
Tablet | Landscape | Portrait | Reverse landscape | Reverse portrait |
---|---|---|---|---|
All tablets 2015 and later | ROTATION_90 | ROTATION_0 | ROTATION_270 | ROTATION_180 |
Fire HDX 8.9 (2014) | ROTATION_270 | ROTATION_0 | ROTATION_90 | ROTATION_180 |
Fire HD 7 (2014) | ROTATION_90 | ROTATION_0 | ROTATION_270 | ROTATION_180 |
Fire HD 6 (2014) | ROTATION_90 | ROTATION_0 | ROTATION_270 | ROTATION_180 |
Kindle Fire HDX 8.9" (2013) | ROTATION_270 | ROTATION_0 | ROTATION_90 | ROTATION_180 |
Kindle Fire HDX 7" (2013) | ROTATION_270 | ROTATION_0 | ROTATION_90 | ROTATION_180 |
Kindle Fire HD 7" (2013) | ROTATION_270 | ROTATION_0 | ROTATION_90 | ROTATION_180 |
Kindle Fire HD 8.9" (2012) | ROTATION_270 | ROTATION_0 | ROTATION_90 | ROTATION_180 |
Kindle Fire HD 7" (2012) | ROTATION_270 | ROTATION_0 | ROTATION_90 | ROTATION_180 |
Kindle Fire (2012) | ROTATION_90 | ROTATION_0 | ROTATION_270 | ROTATION_180 |
Kindle Fire (2011) | ROTATION_90 | ROTATION_0 | ROTATION_270 | ROTATION_180 |
Sensor-based Orientation
When creating an app for the Fire tablets that runs only in landscape mode, you should specify sensor-based landscape orientation in your AndroidManifest.xml. With sensor-based orientation, the system chooses landscape orientation or reverse landscape orientation based on the physical orientation of the tablet. Android API level 9 and later supports the attribute for sensor-based orientation.
Include the following in your AndroidManifest.xml file to specify that you want to use sensor-based landscape orientation:
<activity
...
android:screenOrientation="sensorLandscape"
android:configChanges="orientation|screenSize">
...
</activity>
Alternatively, in your code, you can use the following constant:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
Accelerometer
When your app is in landscape orientation on a Fire tablet, for example in a game, use Display.getRotation() to check the display rotation when using raw accelerometer readings. The reference orientation for the Fire tablets is portrait mode, and the accelerometer readings are relative to a fixed coordinate system based on portrait orientation.
You need to translate the sensor data so that it makes sense for the current display rotation. That way, the logic in your app gets the expected input in landscape mode. For example, if you do not check the display rotation in a game, the game logic may move a character in the opposite direction from what the user intended.
Camera Orientation
Most of the Fire tablet devices include a front-facing camera, with the following exceptions:
- Kindle Fire HD 7 (2013)
- Kindle Fire (2012)
- Kindle Fire (2011)
For more information about cameras, see the Fire Tablet Device and Feature Specifications. When creating an app that uses the camera, you should account for the position of the front-facing camera to ensure that the camera preview and captured images have the correct orientation. Do the following to correctly display and save images in your camera app:
- Call Camera.setDisplayOrientation() before initializing the camera, to correctly orient the camera preview. Your app needs to pass a rotation value that accounts for the current rotation of the tablet and the orientation of the camera.
- Call Camera.Parameters.setRotation() from an OrientationListener to ensure that JPEG PictureCallback receives a correctly rotated image. You need to call Camera.Parameters.setRotation() because Camera.setDisplayOrientation affects only the preview and does not change the data provided to the JPEG PictureCallback event. When providing the rotation value to Camera.Parameters.setRotation(), make sure to account for the current rotation of the device and the orientation of the camera.
Last updated: Oct 29, 2020