public final class RotationPolicy extends Object
Modifier and Type | Class and Description |
---|---|
static class |
RotationPolicy.RotationPolicyListener
Listener that is invoked whenever a change occurs that might affect the rotation policy.
|
Modifier and Type | Method and Description |
---|---|
static int |
getRotationLockOrientation(Context context)
Returns the orientation that will be used when locking the orientation from system UI
with
setRotationLock(android.content.Context, boolean) . |
static boolean |
isRotationLocked(Context context)
Returns true if rotation lock is enabled.
|
static boolean |
isRotationLockToggleVisible(Context context)
Returns true if the rotation-lock toggle should be shown in system UI.
|
static boolean |
isRotationSupported(Context context)
Gets whether the device supports rotation.
|
static void |
registerRotationPolicyListener(Context context,
RotationPolicy.RotationPolicyListener listener)
Registers a listener for rotation policy changes affecting the caller's user
|
static void |
registerRotationPolicyListener(Context context,
RotationPolicy.RotationPolicyListener listener,
int userHandle)
Registers a listener for rotation policy changes affecting a specific user,
or USER_ALL for all users.
|
static void |
setRotationLock(Context context,
boolean enabled)
Enables or disables rotation lock from the system UI toggle.
|
static void |
setRotationLockForAccessibility(Context context,
boolean enabled)
Enables or disables natural rotation lock from Accessibility settings.
|
static void |
unregisterRotationPolicyListener(Context context,
RotationPolicy.RotationPolicyListener listener)
Unregisters a listener for rotation policy changes.
|
public static boolean isRotationSupported(Context context)
context
- Context for accessing system resources.public static int getRotationLockOrientation(Context context)
setRotationLock(android.content.Context, boolean)
.
If the device only supports locking to its natural orientation, this will be either
Configuration.ORIENTATION_PORTRAIT or Configuration.ORIENTATION_LANDSCAPE,
otherwise Configuration.ORIENTATION_UNDEFINED if any orientation is lockable.public static boolean isRotationLockToggleVisible(Context context)
public static boolean isRotationLocked(Context context)
public static void setRotationLock(Context context, boolean enabled)
public static void setRotationLockForAccessibility(Context context, boolean enabled)
public static void registerRotationPolicyListener(Context context, RotationPolicy.RotationPolicyListener listener)
public static void registerRotationPolicyListener(Context context, RotationPolicy.RotationPolicyListener listener, int userHandle)
public static void unregisterRotationPolicyListener(Context context, RotationPolicy.RotationPolicyListener listener)