阅读陀螺仪的问题

时间:2017-10-03 13:05:44

标签: android gyroscope

我正在开发一款能够读取陀螺仪并使用其值生成图形的应用程序。我已经使用加速度计(Sensor.TYPE_ACCELEROMETER)来做到这一点并且它运行良好,但是当我使用陀螺仪(Sensor.TYPE_GYROSCOPE)时,应用程序关闭。

我正在使用SDK 16,并且在课堂上将 type_gyroscope 标记为已弃用,但我尝试了SDK 21并继续遇到同样的问题。有人知道发生了什么吗?

LogCat:

10-05 02:10:58.117 3934-3934 / com.smartapps.accel E / SensorManager:传感器或监听器为空 10-05 02:11:00.700 3934-3934 / com.smartapps.accel D / AndroidRuntime:关闭VM ---------崩溃开始 10-05 02:11:00.703 3934-3934 / com.smartapps.accel E / AndroidRuntime:FATAL EXCEPTION:main                                                                    处理:com.smartapps.accel,PID:3934                                                                    java.lang.IndexOutOfBoundsException:Index:0,Size:0                                                                        at java.util.ArrayList.get(ArrayList.java:437)                                                                        at com.smartapps.accel.MainActivity.openChart(MainActivity.java:114)                                                                        at com.smartapps.accel.MainActivity.onClick(MainActivity.java:103)                                                                        在android.view.View.performClick(View.java:6256)                                                                        在android.view.View $ PerformClick.run(View.java:24697)                                                                        在android.os.Handler.handleCallback(Handler.java:789)                                                                        在android.os.Handler.dispatchMessage(Handler.java:98)                                                                        在android.os.Looper.loop(Looper.java:164)                                                                        在android.app.ActivityThread.main(ActivityThread.java:6541)                                                                        at java.lang.reflect.Method.invoke(Native Method)                                                                        在com.android.internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:240)                                                                        在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

0 个答案:

没有答案