Hello Guys,
i have an issue with my "onSensorChanged" event. I write a test app to acces my accelator sensor on the "Samsung Galaxy S5 Mini". This is my code:
My MainActivity implements the SensorEventListener:
And i implement onSensorChanged and onAccuracyChanged as well:
Not even "Log.d("Test", "SensorChange");" is called a single time.
Im workink with Android Studio 0.8.14 at the moment. I use a older version cause i got some truble to import 0.8.14 project to the version 1.0. The wierd thing is that i create a simillar app with eclipse some days ago. And got no issues to read the accelator sensor. I would be glad if someone knows how to solve this problem.
i have an issue with my "onSensorChanged" event. I write a test app to acces my accelator sensor on the "Samsung Galaxy S5 Mini". This is my code:
My MainActivity implements the SensorEventListener:
Code:
public class MainActivity extends Activity implements SensorEventListener {
Code:
@Override
public void onSensorChanged(SensorEvent event) {
Log.d("Test", "SensorChange"); //never called
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
float[] vals = event.values.clone();
tvX.setText("X: " + Float.toString(vals[0]));
tvY.setText("Y: " + Float.toString(vals[1]));
tvZ.setText("Z: " + Float.toString(vals[2]));
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
Im workink with Android Studio 0.8.14 at the moment. I use a older version cause i got some truble to import 0.8.14 project to the version 1.0. The wierd thing is that i create a simillar app with eclipse some days ago. And got no issues to read the accelator sensor. I would be glad if someone knows how to solve this problem.
0 commentaires:
Enregistrer un commentaire