Start short Vibrate - Android Hardware

Android examples for Hardware:Vibrator

Description

Start short Vibrate

Demo Code


//package com.java2s;
import android.app.Service;
import android.content.Context;
import android.os.Vibrator;

public class Main {
    public static void shortVibrate(Context context) {
        Vibrator vibrator = (Vibrator) context
                .getSystemService(Service.VIBRATOR_SERVICE);
        vibrator.vibrate(50);/*  w  w  w .  j av  a  2  s  .  co  m*/
    }

    public static void vibrate(Context context, long time) {
        if (time > 1000) {
            return;
        }
        Vibrator vibrator = (Vibrator) context
                .getSystemService(Service.VIBRATOR_SERVICE);
        vibrator.vibrate(time);
    }
}

Related Tutorials