vendredi 19 décembre 2014

onSensorChanged not called topic

11:14






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:


Code:


public class MainActivity extends Activity implements SensorEventListener {

And i implement onSensorChanged and onAccuracyChanged as well:


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) {

    }


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.






Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 commentaires:

Enregistrer un commentaire

 

© 2013 Mobile Probleme. All rights resevered. Designed by Templateism

Back To Top