开发者

How to correctly dispose a SensorManager

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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜