Using Vibrator : Vibrator « Hardware « Android






Using Vibrator

  
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Vibrator;

 class Utils {

  public static SharedPreferences preferencias;
  public static Vibrator v;
  public static final int CORTO = 50;
  public static final int LARGO = 500;
  
  
  static public void vibrar(Context ctx, int t){
    //boolean activo = Utils.p.getBoolean("cbVibrar", true);
    if(!preferencias.getBoolean("cbVibrar", true)) return;
    v = (Vibrator) ctx.getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(t);
  }

  
}

   
    
  








Related examples in the same category

1.Demonstrates android.os.Vibrator android.os.Vibrator class.