Skip to content Skip to sidebar Skip to footer

Android: Shakelistener Error

i have a shake listener as follows public class ShakeListener implements SensorEventListener { private String TAG = ShakeListener.class.getSimpleName(); private static fina

Solution 1:

add this method in your activity:

    @Override
    protected void finalize() throws Throwable {
        try {
            stop();
        } catch (Exception e){
            e.printStackTrace();
        }
        super.finalize();
    }

    public void stop(){
        try {
            sensorMgr.unregisterListener(this, mAccelerometer);
        } catch (Exception e){
            e.printStackTrace();
        }
    }

Post a Comment for "Android: Shakelistener Error"