我使用这个 android 代码,当用户触摸屏幕时,振动开始并持续 3000 毫秒。我不希望用户总是触摸屏幕,振动的持续时间与以前的时间(3000 毫秒)相同。我想使用随机的,每次振动持续随机的时间。我应该如何根据我的代码使用随机数?
请帮我。
public boolean dispatchTouchEvent(MotionEvent ev)
{
if (ev.getAction() == MotionEvent.ACTION_UP)
{
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(3000);
}
return super.dispatchTouchEvent(ev);
}