0

#

i want to try counting shake on android and show it on textview, but keep crashing after i try shaking. here's my code.

private final SensorEventListener mSensorListener = new SensorEventListener() {

    public void onSensorChanged(SensorEvent se) {
        float x = se.values[0];
        float y = se.values[1];
        float z = se.values[2];
        mAccelLast = mAccelCurrent;
        mAccelCurrent = (float) Math.sqrt((double) (x * x + y * y + z * z));
        float delta = mAccelCurrent - mAccelLast;
        mAccel = mAccel * 0.9f + delta; // perform low-cut filter
        if (mAccel > 10) {
            max = 100;
            for (i=1; i<=max;) {
                i=i+1;
                TextView angka = (TextView) findViewById(R.id.angka);
                angka.setText(i);
            }
        }
    }
Okaba
  • 1
  • 1

0 Answers0