0

在此处输入图像描述 我的应用中只有 2 个振动呼叫

1. Vibration Call 

listView.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, final View view,
                        int position, long id) {
...
    vibrator.vibrate(200);
...}
}

2. Vibration Call    

public void onSensorChanged(SensorEvent event) {
            if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
    }
    ....
//z axes accelerator changes
    long[] pattern = { 0, 200, 200 };
                    vibrator.vibrate(pattern, 3);
    }}

我认为第一个是缓和错误。

我真的没有看到任何错误。

这是我第一次编程振动。

我该如何解决?

4

2 回答 2

0

目前最好的解决方案是

Handler handler = new Handler();
handler.post(new Runnable() {
        public void run() {
vibrator.vibrate(200);
        }

});
}

应用程序不会崩溃,但振动有时会失败

于 2013-03-08T12:09:57.760 回答
-1

我认为这会奏效

long[] pattern = new long[]{ 0, 200, 200 };
                    vibrator.vibrate(pattern, 3);
于 2013-03-08T11:46:37.493 回答