android手机振动

public static void vibrate(Vibrator vibrator){
		vibrator.vibrate(500);//振动500毫秒
		//停200毫秒,振动200毫秒,停300毫秒,振动300毫秒,停1秒,振动1秒
		//long [] pattern = {200,200,300,300,1000,1000};
		//vibrator.vibrate(pattern,-1);//-1不重复,0循环振动 1,从1位置循环振动
	}


添加权限


 

vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);

import android.os.Vibrator;

你可能感兴趣的:(android)