How to simulate Android sensor events?

Is it possible to simulate, for example, events for the android accelerometer?

Imagine the following scenario: I have an application that at some point, if it detects the value X from the accelerometer, displays a dialog with a question to the user interface.

I want to do a test for him. To do this, I want to programmatically simulate a jitter with this X value and check if a dialog box appears.

I already know Sensor Simulator , but is there a way to send a value for an accelerometer or other sensor and get it using a SensorEventListener?

Thanks in advance,

+6
source share
1 answer

It's impossible. Because a sensor event is triggered by hardware, the Android system receives data from the hardware and does not provide an interface for modifying data or for triggering a sensor event. Therefore, we cannot simulate a sensor event programmatically. Use Sensor Simulator, or you can change the source code of the Android framework.

0
source

All Articles