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
  • 53,910
  • 52
  • 193
  • 240
Jyosna
  • 4,436
  • 13
  • 60
  • 93

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
  • 22,400
  • 10
  • 55
  • 79
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,181
  • 2
  • 20
  • 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
  • 19,631
  • 51
  • 159
  • 265