Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.os.Vibrator; public class Main { private static final long[] SHAKE_MIC_PATTERN = { 300L, 200L }; /** * msg shake * * @param context * @param isShake */ public static void shakeControlMic(Context context, boolean isShake) { Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); if (vibrator == null) { return; } if (isShake) { vibrator.vibrate(SHAKE_MIC_PATTERN, -1); return; } vibrator.cancel(); } }