How could I trigger the event related to an screen touch in a given coordinate, regardless of device state?
I have users that are unable to touch the device (they lack body movement, due to cerebral palsy or strokes). I am then in the process of creating a device that monitorates other types of input (for instance muscle contraction, or even throat humming, among others).
The important part is that I have a circuit that emits a single command.
These commands must then be intercepted by the Android device, and execute its associated command, as if the user was normally operating the device.
Note the following: I will not have any Activity running. The purpose of the application is to interface the sensor with the device, and thus, I cannot make use of View elements.
I suppose what I want to perform is to create a mouse-like
element for Android.
But I have not come with any way to either have an application be executed inside my own (where I would provide an automated moving "target" for the user to issue a command/click) or a way to perform an MotionEvent or KeyEvent.
While my research so far yielded no response, I would like to ask the following: Am I forgetting any part or directive of the system that could allow me to perform my task?
The final outcome, is a Service, this service is merely waiting for a signal, this is captured by a Receiver... this is where I am stuck.
You can click a button programmatically by using the button. performClick() method.
To define the click event handler for a button, add the android:onClick attribute to the <Button> element in your XML layout. The value for this attribute must be the name of the method you want to call in response to a click event. The Activity hosting the layout must then implement the corresponding method.
Link the button from the XML by calling findViewById() method and set the onClick listener by using setOnClickListener() method. setOnClickListener takes an OnClickListener object as the parameter. Basically it's creating an anonymous subclass OnClickListener in the parameter.
You are going to have a very hard time injecting Events from your app into any other app, due to security reasons.
However, you might have better luck in native land, C/C++. So hopefully your sensor-wrapper will end up as a .SO lib which can be included in other projects...
Because what you're trying to do kinda sounds like what Espresso can do (it's a JUnit test suite that can inject Motion/Touch/KeyEvents into views)
However, you can compile your own image with some added accessibility apps that might get you there. But your idea is really not going to be applicable to just about any off-the-shelf android device.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With