RotationProvider
class RotationProvider
Provider for receiving rotation updates from the SensorManager when the rotation of the device has changed.
This class monitors motion sensor and notifies the listener about physical orientation changes in the format of Surface rotation. It's useful when the Activity is in a fixed portrait or landscape orientation, while the app still wants to set the UseCase target rotation based on the device's physical rotation.
// Create a provider. RotationProvider mRotationProvider = new RotationProvider(getContext()); // Add listener to receive updates. mRotationProvider.addListener(rotation -> { mImageCapture.setTargetRotation(rotation); }); // Remove when no longer needed. mRotationProvider.clearListener();
Summary
Nested types |
|---|
interface RotationProvider.ListenerCallback interface to receive rotation updates. |
Public constructors |
|---|
RotationProvider(context: Context)Creates a new RotationProvider. |
Public functions |
|
|---|---|
Boolean |
addListener(executor: Executor, listener: RotationProvider.Listener)Sets a |
Unit |
removeListener(listener: RotationProvider.Listener)Removes the given |
Public constructors
Public functions
addListener
fun addListener(executor: Executor, listener: RotationProvider.Listener): Boolean
Sets a Listener that listens for rotation changes.
| Parameters | |
|---|---|
executor: Executor |
The executor in which the |
removeListener
fun removeListener(listener: RotationProvider.Listener): Unit
Removes the given Listener from this object.
The removed listener will no longer receive rotation updates.