hatebin -1 Newbie Poster

Hi,
I'm tring to create an application to count steps and i need to know how to use gravity sensors in smartphones in android. Do you have any suggestions how could i do that ?
What I already have is a simple app to count pushups but it is based on an accaelerator and it it's not very accured. And i need a better solution than that.

public void onSensorChanged(int sensor, float[] values) {

            if (sensor == SensorManager.SENSOR_ACCELEROMETER) {
               Axbox.setText("Accel X: " + values[0]);
               Aybox.setText("Accel Y: " + values[1]);
                Azbox.setText("Accel Z: " + values[2]);
            }            

            if(values[1]<0.15000 && values[1]>-0.16000){
                Oxbox.setText("Pushups: "+ pushup++);

            }

    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.