Sending data to onSensorChanged if the SensorEvent constructor is not displayed

I am trying to write a service for testing a class that implements onSensorChanged(SensorEvent event)by passing its data, which I can create as if it came from a sensor. The problem I am facing is that I cannot create my own SensorEvent objects to pass a function because SensorEvent does not have public constructors. I tried to create my own class, which would have the necessary SensorEvent functions and cast it, but since then I found that in order to be able to distinguish it, it had to be a subclass and subclassed it, I would have to have access to the constructor .

Is there any other way to create an object that I can pass in place of a SensorEvent, or is there a better approach to modeling the missing functions?

+3
source share
2 answers

The SensorSimulator project is probably doing the testing you are trying to do. But if not, it should have code that can help

0
source

Unfortunately, the SensorSimulator project is impractical because the developer must make changes to the code in order to use it. Even after making changes to the code, it does not work very well, because it is not supported and is outdated. So far, I have not found a simple and direct solution to this problem. For this I try AspectJ. Will report if I find a solution to the problem.

0
source

All Articles