Code example for GLSurfaceView

Methods: onResume

0
    @Override 
    protected void onResume() { 
        // Ideally a game should implement onResume() and onPause() 
        // to take appropriate action when the activity looses focus 
        super.onResume(); 
        mGLSurfaceView.onResume();
        Sensor gsensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        Sensor msensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
        mSensorManager.registerListener(this, gsensor, SensorManager.SENSOR_DELAY_GAME);
        mSensorManager.registerListener(this, msensor, SensorManager.SENSOR_DELAY_GAME);
    } 
 
    @Override 
    protected void onPause() { 
        // Ideally a game should implement onResume() and onPause() 
        // to take appropriate action when the activity looses focus 
        super.onPause(); 
        mGLSurfaceView.onPause();
        mSensorManager.unregisterListener(this);
    }