Hey, I am using a SensorManager in my Android application. I understand that I have to dispose it in some way once the application is closed, because otherwise it would continue to listen to changes开发者_JAVA百科. So I tried the following:
@Override
public void onDestroy()
{
manager.unregisterListener(temp);
}
(when temp was an instance of TempListener extends SensorEventListener, and it was added to the SensorManager manager with manager.registerListener(temp...)). I also tried manager = null, but they all cause me the application to force close. Where am I going wrong? Thank you.
The problem was that I didn't write super.onDestroy(). Silly me...
精彩评论