[英]android runtime error vibration
have only 2 vibration calls in my app 我的应用中只有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);
}}
I think first one is coasing the error. 我认为第一个是解决错误。
I really do not see any error. 我真的没有看到任何错误。
Its my first time programming vibration. 这是我第一次编程振动。
How do I fix this? 我该如何解决?
For now best solution is 目前最好的解决方案是
Handler handler = new Handler();
handler.post(new Runnable() {
public void run() {
vibrator.vibrate(200);
}
});
}
App does not crash but vibration sometimes fails 应用程序不会崩溃,但振动有时会失败
I think this will work 我认为这会起作用
long[] pattern = new long[]{ 0, 200, 200 };
vibrator.vibrate(pattern, 3);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.