Im trying to realize something similar, posted on this thread. My intention was to build a Service, which creates KeyEvents like (DPAD_UP, DPAD_DOWN ...). I have already tried every method, and none of them is working! The Method in this thread is not working or no more available in my SDK (rev 5).
mandroid wrote:Hi pskink,
i want to write an app, which can remote control an Android-Device. The remote-aspect is another problem. First of all i want to find out how to inject KeyEvents. Afterwards i guess im' going to try sending keyCodes over USB/Bluetooth or socket to an Android-Device.
Why is it a bad idea to inject KeyEvents? Is it generally a bad idea, or is it bad in the way i am doing it :) ?
if you to call some action which is invoked when you press some key, why not to call it directly ?
key events are propagated to focused view, do you have any control which view is focused or not?
and finally even if you could send key event you could send it only to your app
mandroid wrote:this is why i try to realize it within a service.
mandroid wrote:No i have no control about focused views. The idea, that i need to get a focused view came to me 5 min ago :( . Now i'm searching inside the Android reference for a method to get the current focused view. Maybe you know a method to do this?
mandroid wrote:Or, to describe my intend in a simplified way:
I want to press a "UP" on my Computer and get the appropriate reaction (DPAD_UP) on my Android-device (and so on ...)
you could call this a "remote keyboard" for android :)
Furthermore is still don't get it, why it should be a bad idea to inject KeyEvents (sorry :?)
so your app has no gui at all and you want to control other apps by sending key events to them?
from obvious security reasons its impossible
would you like some service to access it and delete some of your data without your knowledge?
mandroid wrote:from obvious security reasons its impossible
nope, via "android debug bridge" something like this is possible. If you connect to the device-shell over "adb shell" you can inject KeyEvents with the shell-command "input keyevent <keycode>".
Users browsing this forum: No registered users and 7 guests