private SensorEventListener speed_listener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
//取绝对值,当任意方向加速度大于15,则认为出发摇一摇
float x_values = Math.abs(event.values[0]);
float y_valyes = Math.abs(event.values[1]);
float z_values = Math.abs(event.values[2]);
if (x_values > 16 || y_valyes > 16 || z_values > 16) {
//Toast.makeText(MainActivity.this,"请2S后重试",Toast.LENGTH_SHORT).show();
sensor_speed.setText("yaoyiyao");
Log.d("Main","yaoyiy");
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
};要怎么样才能在一段时间里面触发一次
11-04 17:14:29.446 18918-18918/com.example.asus.myapplication D/Main: yaoyiy
11-04 17:14:29.587 18918-18918/com.example.asus.myapplication D/Main: yaoyiy
11-04 17:14:29.728 18918-18918/com.example.asus.myapplication D/Main: yaoyiy
11-04 17:14:29.870 18918-18918/com.example.asus.myapplication D/Main: yaoyiy
11-04 17:14:30.010 18918-18918/com.example.asus.myapplication D/Main: yaoyiy
11-04 17:14:30.151 18918-18918/com.example.asus.myapplication D/Main: yaoyiy
11-04 17:14:30.364 18918-18918/com.example.asus.myapplication D/Main: yaoyiy
11-04 17:14:30.858 18918-18918/com.example.asus.myapplication D/Main: yaoyiy
1 回答
- 1 回答
- 1 关注
- 1790 浏览
添加回答
举报
0/150
提交
取消