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
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
Use SensorEventListener
instead. There is quite good explanation of it in the docs. Accelorometer is probably the sensor you want to use here.
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.
Here is an exemple of how to use the sensor manager class on android:
http://developer.android.com/reference/android/hardware/SensorManager.html