Package 

Class RotationMonitor

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public interface RotationMonitor.Listener

      Defines the contract of listener that can receive notifications about device rotation changes.

    • Constructor Summary

      Constructors 
      Constructor Description
      RotationMonitor(Context context) Constructs a new rotation monitor for the given context.
    • Method Summary

      Modifier and Type Method Description
      synchronized RotationMonitor.Listener getListener() Gets reference to the current listener that will be notified when an rotation change is detected.
      synchronized void setListener(@Nullable() RotationMonitor.Listener listener) Sets reference to the current listener that must be notified when an rotation change is detected.
      void startTracking() Starts the rotation monitor to start tracking for device rotation changes.
      void stopTracking() Stops the rotation monitor.
      int getRotation() Returns the rotation of the screen from its "natural" rotation.The returned value may be Surface.ROTATION_0 (no rotation), Surface.ROTATION_90,Surface.ROTATION_180, or Surface.ROTATION_270.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RotationMonitor

        RotationMonitor(Context context)
        Constructs a new rotation monitor for the given context.
        Parameters:
        context - the context of the view that owns this rotation monitor.
    • Method Detail

      • setListener

         synchronized void setListener(@Nullable() RotationMonitor.Listener listener)

        Sets reference to the current listener that must be notified when an rotation change is detected.

        Parameters:
        listener - reference the rotation listener.
      • startTracking

         void startTracking()

        Starts the rotation monitor to start tracking for device rotation changes.

      • stopTracking

         void stopTracking()

        Stops the rotation monitor.

      • getRotation

         int getRotation()

        Returns the rotation of the screen from its "natural" rotation.The returned value may be Surface.ROTATION_0 (no rotation), Surface.ROTATION_90,Surface.ROTATION_180, or Surface.ROTATION_270. For example, if a device has a naturally tallscreen, and the user has turned it on its side to go into a landscape rotation, the valuereturned here may be either Surface.ROTATION_90 or Surface.ROTATION_270 depending on thedirection it was turned. The angle is the rotation of the drawn graphics on the screen,which is the opposite direction of the physical rotation of the device. For example, if thedevice is rotated 90 degrees counter-clockwise, to compensate rendering will be rotatedby 90 degrees clockwise and thus the returned value here will be Surface.ROTATION_90.