android - 实施重要运动传感器的正确方法是什么?
问题描述
我在我的活动中放置了来自https://developer.android.com/guide/topics/sensors/sensors_motion#sensors-motion-significant的重要运动传感器代码。但是应用程序一启动就崩溃了。实施重要运动传感器的正确方法是什么?
解决方案
如果
mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION,true);
返回 null 很可能您的设备不支持此传感器。您应该考虑直接使用 Accelerator 作为替代方案。
推荐阅读
- angular6 - Angular 6 - 使用 window.location.reload() 时重复重新加载页面
- python - rtype 在 Python 中是什么意思?
- fullcalendar - FullCalendar - 垂直时间线,水平天数
- class - Java 8 检查扩展另一个对象的对象的类或实例
- websocket - 根据有效负载从效果中切换最终发出的动作
- java - 嵌套地图上的流
- jquery - 数据表中的自定义过滤器地址和日期范围
- javascript - 更改用户 Firebase 身份验证时触发的事件
- arrays - Xcode Time Profiler 的详细信息面板显示“main”是应用程序运行缓慢的原因,但没有在其中显示单独的方法调用。
- java - 为什么下面的按位运算会产生数值溢出?