Example usage for android.content Context VIBRATOR_SERVICE

List of usage examples for android.content Context VIBRATOR_SERVICE

Introduction

In this page you can find the example usage for android.content Context VIBRATOR_SERVICE.

Prototype

String VIBRATOR_SERVICE

To view the source code for android.content Context VIBRATOR_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.os.Vibrator for interacting with the vibration hardware.

Usage

From source file:Main.java

public static void vibrate(Context context, long duration) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    long[] pattern = { 0, duration };
    vibrator.vibrate(pattern, -1);/* w w w  .ja  va  2s.c o m*/
}

From source file:Main.java

public static void vibrate(Context context, long milliseconds) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(milliseconds);//from   w  w  w  .  j  a v a2 s .c o  m
}

From source file:Main.java

public static void doVibrate(Context context, int time) {

    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrator != null) {
        vibrator.cancel();// w  w w . ja v a2s.  c o m

        vibrator.vibrate(time);
    }
}

From source file:Main.java

public static void vibrate(final Context context, final long milliseconds) {
    Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(milliseconds);/*from   w  ww . ja  v a 2  s . co m*/
}

From source file:Main.java

public static void vibrate(Context context, long timeMs) {
    ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(timeMs);
}

From source file:Main.java

public static void startVibrator(Context context) {
    int vibrateTime = 1000;
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(vibrateTime);//from  www . j a  v a 2s.com
}

From source file:Main.java

public static void vibrate(Activity activity, long time) {
    Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(time);/*  ww w . j  a  v  a 2  s. c om*/
}

From source file:Main.java

public static void vibration(Context context) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(100);
}

From source file:Main.java

public static void vibrate(Context context, long[] pattern) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(pattern, -1);/*from  ww w .  j a v  a  2  s.  co  m*/
}

From source file:Main.java

public static void provideHapticFeedback(Context context) {
    if (sVibrator == null)
        sVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);

    sVibrator.vibrate(50);//from  www  . ja  va2s .  c o m
}