首页 > 解决方案 > 实施重要运动传感器的正确方法是什么?

问题描述

我在我的活动中放置了来自https://developer.android.com/guide/topics/sensors/sensors_motion#sensors-motion-significant的重要运动传感器代码。但是应用程序一启动就崩溃了。实施重要运动传感器的正确方法是什么?

标签: androidsignificant-motion-sensor

解决方案


如果

mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION,true);

返回 null 很可能您的设备不支持此传感器。您应该考虑直接使用 Accelerator 作为替代方案。


推荐阅读