Soft click on a View item from another application

I want to write a service that is in the background, and when I click the headset’s multimedia button, a specific ListView element from another application will be clicked.

Now I can only activate a specific action that has only a ListView element. Is it possible to trigger such a click event (think about creating any shortcuts or macros, for example AutoHotkey in windows).

I just stumbled upon this blog post: http://mylifewithandroid.blogspot.com/2009/01/generating-keypresses-programmatically.html

I also know

View.performClick() 

event. I can also mention that I can see the source code of the application in which I want to make a shortcut, but I cannot change and redistribute it. If this is not possible on a vanilla android, and not at the root?

+4
source share
1 answer

Think about what you are doing conceptually. Do you really want your program to understand external events as internal clicks?

Instead, specify both events (internal click and external event) for the same internal behavior.

 externalEvent() -> performClick() // doesn't sound good. externalEvent() -> doSomething(); onClick() -> doSomething(); // looking better 
-3
source

Source: https://habr.com/ru/post/1398059/


All Articles