Android Vibrator Vibrate vibrate(Context context, int duration)

Here you can find the source of vibrate(Context context, int duration)

Description

vibrate

Declaration

public static void vibrate(Context context, int duration) 

Method Source Code

//package com.java2s;
import android.Manifest.permission;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Vibrator;

public class Main {
    public static void vibrate(Context context, int duration) {
        if (hasVibrationPermission(context)) {
            ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE))
                    .vibrate(duration);/*from  w  w w.ja v a2 s .  com*/
        }
    }

    private static boolean hasVibrationPermission(Context context) {
        int result = context
                .checkCallingOrSelfPermission(permission.VIBRATE);
        return (result == PackageManager.PERMISSION_GRANTED);
    }
}

Related

  1. Vibrate(final Activity activity, long milliseconds)
  2. Vibrate(final Activity activity, long[] pattern, boolean isRepeat)
  3. vibrar(Context context)
  4. vibrar(Context context, long tempo)