Search in sources :

Example 1 with VibrationEffect

use of android.os.VibrationEffect in project Gadgetbridge by Freeyourgadget.

the class FindPhoneActivity method vibrate.

private void vibrate() {
    mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    long[] vibrationPattern = new long[] { 1000, 1000 };
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        VibrationEffect vibrationEffect = VibrationEffect.createWaveform(vibrationPattern, 0);
        mVibrator.vibrate(vibrationEffect);
    } else {
        mVibrator.vibrate(vibrationPattern, 0);
    }
}
Also used : VibrationEffect(android.os.VibrationEffect)

Example 2 with VibrationEffect

use of android.os.VibrationEffect in project Signal-Android by WhisperSystems.

the class VibrateUtil method vibrateTick.

public static void vibrateTick(@NonNull Context context) {
    Vibrator vibrator = ServiceUtil.getVibrator(context);
    if (Build.VERSION.SDK_INT >= 26) {
        VibrationEffect effect = VibrationEffect.createOneShot(TICK_LENGTH, 64);
        vibrator.vibrate(effect);
    } else {
        vibrator.vibrate(TICK_LENGTH);
    }
}
Also used : Vibrator(android.os.Vibrator) VibrationEffect(android.os.VibrationEffect)

Example 3 with VibrationEffect

use of android.os.VibrationEffect in project Signal-Android by signalapp.

the class VibrateUtil method vibrateTick.

public static void vibrateTick(@NonNull Context context) {
    Vibrator vibrator = ServiceUtil.getVibrator(context);
    if (Build.VERSION.SDK_INT >= 26) {
        VibrationEffect effect = VibrationEffect.createOneShot(TICK_LENGTH, 64);
        vibrator.vibrate(effect);
    } else {
        vibrator.vibrate(TICK_LENGTH);
    }
}
Also used : Vibrator(android.os.Vibrator) VibrationEffect(android.os.VibrationEffect)

Example 4 with VibrationEffect

use of android.os.VibrationEffect in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VibrationPreferenceFragment method playVibrationPreview.

/**
 * Play a vibration effect with intensity just selected by user
 */
protected void playVibrationPreview() {
    Vibrator vibrator = getContext().getSystemService(Vibrator.class);
    VibrationEffect effect = VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
    AudioAttributes.Builder builder = new AudioAttributes.Builder();
    builder.setUsage(getPreviewVibrationAudioAttributesUsage());
    vibrator.vibrate(effect, builder.build());
}
Also used : AudioAttributes(android.media.AudioAttributes) Vibrator(android.os.Vibrator) VibrationEffect(android.os.VibrationEffect)

Example 5 with VibrationEffect

use of android.os.VibrationEffect in project android_packages_apps_Settings by omnirom.

the class VibrationPreferenceFragment method playVibrationPreview.

/**
 * Play a vibration effect with intensity just selected by user
 */
protected void playVibrationPreview() {
    Vibrator vibrator = getContext().getSystemService(Vibrator.class);
    VibrationEffect effect = VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
    AudioAttributes.Builder builder = new AudioAttributes.Builder();
    builder.setUsage(getPreviewVibrationAudioAttributesUsage());
    vibrator.vibrate(effect, builder.build());
}
Also used : AudioAttributes(android.media.AudioAttributes) Vibrator(android.os.Vibrator) VibrationEffect(android.os.VibrationEffect)

Aggregations

VibrationEffect (android.os.VibrationEffect)5 Vibrator (android.os.Vibrator)4 AudioAttributes (android.media.AudioAttributes)2