Example usage for android.os Vibrator vibrate

List of usage examples for android.os Vibrator vibrate

Introduction

In this page you can find the example usage for android.os Vibrator vibrate.

Prototype

@RequiresPermission(android.Manifest.permission.VIBRATE)
    public void vibrate(VibrationEffect vibe, AudioAttributes attributes) 

Source Link

Usage

From source file:Main.java

public static void vibrate(final Activity activity, long[] pattern, boolean isRepeat) {
    Vibrator vib = (Vibrator) activity.getSystemService(Service.VIBRATOR_SERVICE);
    vib.vibrate(pattern, isRepeat ? 1 : -1);
}

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 source file:Main.java

public static void Vibrate(final Activity activity, long[] pattern, boolean isRepeat) {
    Vibrator vib = (Vibrator) activity.getSystemService(Service.VIBRATOR_SERVICE);
    vib.vibrate(pattern, isRepeat ? 1 : -1);
}

From source file:Main.java

public static void Vibrate(final Context context, long[] pattern, boolean isRepeat) {
    Vibrator vib = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
    vib.vibrate(pattern, isRepeat ? 1 : -1);
}

From source file:Main.java

public static void vibrate(final Context context, long[] pattern, boolean isRepeat) {
    Vibrator vib = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
    vib.vibrate(pattern, isRepeat ? 1 : -1);
}

From source file:Main.java

public static void vibrate(Context context, long[] pattern, int repeat) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(pattern, repeat);
}

From source file:Main.java

public static void vibratePattern(Context context, long... pattern) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(pattern, -1);
}

From source file:Main.java

public static void Vibrate(Context context, long[] pattern, boolean isRepeat) {
    try {/*from  w  ww .j a  v a  2 s. c o  m*/
        Vibrator vib = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
        vib.vibrate(pattern, isRepeat ? 1 : -1);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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);
}

From source file:Main.java

/**
 * msg shake//ww  w . j  ava  2  s  .  c  om
 * 
 * @param context
 * @param isShake
 */
public static void shake(Context context, boolean isShake) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrator == null) {
        return;
    }
    if (isShake) {
        vibrator.vibrate(SHAKE_PATTERN, -1);
        return;
    }
    vibrator.cancel();
}