在我的应用中只有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);
}}
我认为第一个是考虑错误。
我真的没有看到任何错误。
这是我第一次编程振动。
我该如何解决这个问题?
答案 0 :(得分:0)
目前最好的解决方案是
Handler handler = new Handler();
handler.post(new Runnable() {
public void run() {
vibrator.vibrate(200);
}
});
}
应用程序不会崩溃,但振动有时会失败
答案 1 :(得分:-1)
我认为这会起作用
long[] pattern = new long[]{ 0, 200, 200 };
vibrator.vibrate(pattern, 3);