0

*** ANSWER: As pointed by DeeV, this question was already covered here. I can't figure out how to close this question as DUPLICATE

I have been testing with motion detection and I have had good results. But there is one small error that I have absolutely no idea how to troubleshoot. When I implement the following:

public class MainActivity extends Activity implements SensorEventListener 

private SensorManager mSensorManager;

// ... OnCreate..

mSensorManager = (SensorManager) getSystemService(this.SENSOR_SERVICE);

On any activity, it executes well on android devices with androd 2.1-upate1, an 4.0.3. On the emulator however, it only works on 4.0.3. On 2.1 The virtual device simply hangs on execution, on logcat there is no message. Removing this line:

mSensorManager = (SensorManager) getSystemService(this.SENSOR_SERVICE);

Then allows the activity to start.

I now the issue must be my environment; I reainstalled sdk but the problem remains.I have only tried this in my pc. Who can give me an idea of what is happening?

Community
  • 1
  • 1
quinestor
  • 1,432
  • 4
  • 19
  • 40

1 Answers1

1

Simple answer, You can't use some emulators to test sensors. They seemed to have fixed that since then, but the 2.1 emulator is still useless. According to this, you can bypass it by disabling the sensors that you're trying to retrieve. It will work as if the sensor did not exist so you can at least test your app as if it was a device that couldn't use the accelerometer.

Community
  • 1
  • 1
DeeV
  • 35,865
  • 9
  • 108
  • 95