vibrate by time - Android Hardware

Android examples for Hardware:Vibrator

Description

vibrate by time

Demo Code


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

public class Main {
    public static void vibrate(Context context, long time) {
        if (time > 1000) {
            return;
        }/*from   w w  w  . j  a v  a 2 s  .c o  m*/
        Vibrator vibrator = (Vibrator) context
                .getSystemService(Service.VIBRATOR_SERVICE);
        vibrator.vibrate(time);
    }
}

Related Tutorials