У меня есть длинный и лат с устройства Android, но мой результат не достаточно хорош. Я имею в виду мой результат Int номер: 37,0 или 260,0 .. Я хочу, чтобы это число двойной 37,001 - 37,999onSensorChanged of android device
Мой код:
// record the compass picture angle turned
private float currentDegree = 0f;
// device sensor manager
private SensorManager mSensorManager;
@Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
// get the angle around the z-axis rotated
float degree = Math.round(event.values[0]);
tvHeading.setText(Float.toString(degree));
// create a rotation animation (reverse turn degree degrees)
RotateAnimation ra = new RotateAnimation(
currentDegree,
-degree,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF,
0.5f);
// how long the animation will take place
ra.setDuration(210);
// set the animation after the end of the reservation status
ra.setFillAfter(true);
// Start the animation
currentDegree = -degree;
// updateWithNewLocation(l);
}
Надежда на помощь. Благодарю.
Проблема решена: необходимость степени четкости, как это:
float degree = event.values[0];
Другая проблема заключается в: Мой результат составляет от 0,0 до 360,0, я хочу, чтобы результат Acurate между 0,000 до 6400,999
Проблема решена также: , чтобы сделать степень между 0 - 6400, чем:
double result =degree * 17.77777778;
degree = (float) result;
позволяет взять пример: 3200 должно быть 180 .. 180 * 17.77777778 равно 3200. Спасибо, в любом случае. Наслаждайтесь :)
не работает чувак, это то, о чем я думал. – RonYamin
У меня есть редактирование ответа. если он работает любезно, отметьте мой ответ, а также проголосуйте за мой ответ. –
Я решил это сам себе, я отредактировал вопрос. Вы можете взглянуть. Спасибо, в любом случае. – RonYamin