如何避免安卓getSystemService(Context.SENSOR_SERVICE)挂模拟器? [英] How to avoid Android getSystemService(Context.SENSOR_SERVICE) hanging emulator?
问题描述
每当我把这种方法在Android模拟器:
Whenever I call this method in the Android emulator:
SensorManager sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
模拟器挂起。当搜索对于这个问题,我找了很多的这种固定早在2009年引用的,但我目前使用可在当前时刻最新的SDK /工具(2011年12月)。 API级别8 / 2.2。
The emulator hangs. When searching for this problem, I find a lot of references of this being fixed back in 2009, but I'm currently using the latest SDK/Tools available at the current time (Dec 2011). API level 8 / v2.2.
我必须真正落实code检查,如果我运行仿真器中,并避免任何基于传感器code?
Must I really implement code for checking if I run in the emulator and avoid all sensor based code?
推荐答案
我经历了仿真器API7类似的事情:所提到的code使模拟器立刻退出该程序没有任何警告或日志消息。 (API4和放大器; API10都OK了,我没具体测试API8)
I experienced something similar with API7 in the emulator: the mentioned code causes the emulator to quit the program immediatly without any warning or log message. (API4 & API10 are ok; I did not test API8 specifically).
我已经通过设置加速度为false在AVD设置解决它。 (我想是因为在API14 / API15从快照启动加速度的问题这一点。)
I have solved it by setting accelerometer to false in the AVD settings. (I tried this because of issues with the accelerometer in API14/API15 with launch from snapshot.)
问候,
阿尔扬
这篇关于如何避免安卓getSystemService(Context.SENSOR_SERVICE)挂模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!