0

我正在开发一个在应用程序打开 3000 毫秒后开始振动的应用程序。我有这两行代码:

 Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
 v.vibrate(3000);

我想编写一个在用户触摸屏幕后开始振动的 android 代码。请帮我。

4

1 回答 1

3

在你的Activity

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_UP) {
        yourVibrateFunction();
    }

    return super.dispatchTouchEvent(ev);
}
于 2012-03-22T23:02:18.693 回答