切换 Android SensorManager 速度。什么是好的做法?
我有兴趣随着时间的推移在不同的传感器方向速度之间切换以优化程序,即电池寿命。该例程可能会被频繁调用。我正在寻找正确的做法。
sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
sensorManager.registerListener(sensorListener, SensorManager.SENSOR_ORIENTATION, SensorManager.SENSOR_DELAY_FASTEST);
//... 1) unregister then register new speed OR
//... 2) register new speed without registering
sensorManager.unregisterListener(sensorListener);
我是否应该取消注册侦听器,然后向 SensorManager.SENSOR_DELAY_NORMAL 注册
或者
我不应该麻烦地注销监听器吗?
谢谢。
I'm interested to switch between different sensor orientation speeds over time to optimize the program ie.. battery life. The routine may be called very often. I'm looking for the right practice.
sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
sensorManager.registerListener(sensorListener, SensorManager.SENSOR_ORIENTATION, SensorManager.SENSOR_DELAY_FASTEST);
//... 1) unregister then register new speed OR
//... 2) register new speed without registering
sensorManager.unregisterListener(sensorListener);
Should I unregister the listener and then register with SensorManager.SENSOR_DELAY_NORMAL
OR
Should I not bother unregistering the listener?
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论