0

I want when I shake my phone it randomly generate some no. I am working with API2.2 and try to using SensorListener but it shows that it is deprecated. so which one I have to use.

please give me any suggestion how to do this. Thank you

Andro Selva
  • 51,960
  • 51
  • 189
  • 237
Jyosna
  • 4,298
  • 12
  • 58
  • 91

3 Answers3

1

Use SensorEventListener instead. There is quite good explanation of it in the docs. Accelorometer is probably the sensor you want to use here.

Xion
  • 20,785
  • 9
  • 48
  • 77
0

As Xion said, use SensorEventListener. There are many examples of this here on SO; for instance, check out this one. For testing shakes in an emulator, something like SensorSimulator might also help.

Community
  • 1
  • 1
areyling
  • 2,161
  • 2
  • 19
  • 25
0

Here is an exemple of how to use the sensor manager class on android:

http://developer.android.com/reference/android/hardware/SensorManager.html

Milos Cuculovic
  • 1,207
  • 3
  • 17
  • 28