1

Is that possible?

I'm developing a service for disabled people. They can define voice commands and the service can detect the commands and execute them. Like when the user says "scroll down", The service (which is in fact a background process) takes control of screen and scrolls down (regardless of what application is on foreground), or touches a specific position and so forth. I wonder if this is possible in an android device? If not, what about a rooted device? (i.e the service has the root permissions). I know that getting voice input and processing it is possible. My question is about doing actions like touch (Action_Down) or scroll the user interface on behalf of a user.

Note that I don't have access to whatever application is running! In fact my service doesn't know about the application that is running on foreground. It might be a social media app or a messaging app or a game or whatever else! So in fact my service must be capable of defining input events like touch, swipe, scroll etc.

Thanks in advance!

sajjad
  • 834
  • 6
  • 13

1 Answers1

0

Yes, that is possible.

For example, ListView has two methods for programmatic scroll:

listView.setSelection(id); //For instant scroll
listView.smoothScrollToPosition(id); // For smooth scroll

For an example of how to use voice triggered actions - check this answer out

For an example of how to inject events programmatically - check this link out

Community
  • 1
  • 1
  • Thanks mate! Note that I don't have access to whatever application is running! In fact my service doesn't know about the application that is running on foreground. It might be a social media app or a messaging app or a game or whatever else! So in fact my service must be capable of defining input events like touch, swipe, scroll, ... – sajjad Apr 14 '17 at 09:19
  • Oh, I see. It is actually possible to control your android device entirely with voice commands. You can check this out for details - http://www.makeuseof.com/tag/control-android-device-entirely-voice/ – Anuar Serikov Apr 14 '17 at 09:23
  • The thing is, controlling not your own apps programmatically may be quite a serious security issue. But still some folks claim that there are methods of how to do it. Check this link for details - http://www.pocketmagic.net/injecting-events-programatically-on-android/ – Anuar Serikov Apr 14 '17 at 09:27
  • Thanks. The last comment about injecting events programmatically was a great clue. I will choose it as the correct answer if you include it in your answer. – sajjad Apr 14 '17 at 10:21
  • You're welcome! The link to the injecting events is already included to the answer :) – Anuar Serikov Apr 14 '17 at 10:49