Class ShadowVibrator

java.lang.Object
org.robolectric.shadows.ShadowVibrator
Direct Known Subclasses:
ShadowSystemVibrator

@Implements(android.os.Vibrator.class)
public class ShadowVibrator
extends Object
  • Field Details

    • pattern

      protected long[] pattern
  • Constructor Details

  • Method Details

    • setHasVibrator

      public void setHasVibrator​(boolean hasVibrator)
      Controls the return value of Vibrator.hasVibrator() the default is true.
    • setHasAmplitudeControl

      public void setHasAmplitudeControl​(boolean hasAmplitudeControl)
      Controls the return value of Vibrator.hasAmplitudeControl() the default is false.
    • isVibrating

      public boolean isVibrating()
      Returns true if the Vibrator is currently vibrating as controlled by Vibrator.vibrate(long)
    • isCancelled

      public boolean isCancelled()
      Returns true if the Vibrator has been cancelled.
    • getMilliseconds

      public long getMilliseconds()
      Returns the last vibration duration in MS.
    • getPattern

      public long[] getPattern()
      Returns the last vibration pattern.
    • getEffectId

      public int getEffectId()
      Returns the last vibration effect ID of a VibrationEffect#Prebaked (e.g. VibrationEffect#EFFECT_CLICK).

      This field is non-zero only if a VibrationEffect#Prebaked was ever requested.

    • getRepeat

      public int getRepeat()
      Returns the last vibration repeat times.