SensorManager -----传感器管理类

安卓官方给予的解释:

     1、 SensorMananger lets you access the device's sensorsGet an instance of this class by  calling  Context.getSystemService()   with the argument SENSOR_SERVICE.”

    你可以用 Context.getSystemService(SENSOR_SERVICE)得到SensorManager的对象 ,有了它你就可以管理传感器了,其中包含下面提到的方法

   getSensorList

   registerListener

   unregisterListener等。

  2、Always make sure to disable sensors you don't need, especially when your activity is paused. Failing to do so can drain the battery in just a few hours. Note that the system will notdisable sensors automatically when the screen turns off.

    就是说要记得在不用的时候关掉传感器,因为手机黑屏是不会自动关掉传感器的

 

官网上给予的例子:

 public class SensorActivity extends Activity implements SensorEventListener {
      
     private final SensorManager mSensorManager;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值