4

how can I create java events from an new input device on an android device?

2 Answers 2

1

Events will come from input device handlers to kernal handler , then to java input events....

events device file will be /dev/input/eventX ... for keypad X-0,touch X-1 . please follow below link

http://cjix.info/blog/misc/internal-input-event-handling-in-the-linux-kernel-and-the-android-userspace/

Sign up to request clarification or add additional context in comments.

Comments

0

u see, there is a big difference between C and java programming: class libraries vs C API. In java, you don't access the virtual device drivers directly, but instead uses the standard class libraries provided by Java, where the low level libraries accessing the hardware have all been written for you.

http://developer.android.com/reference/android/view/InputEvent.html

http://developer.android.com/reference/android/view/KeyEvent.html

and start navigating around looking for samples.

These low level libraries are in turn written in C, and communicate with Java via JNI / NDK:

http://developer.android.com/sdk/ndk/overview.html

2 Comments

Eh. So what if you want to grab input events while a different app is open? Or while the screen is turned off (assuming that you patched the kernel to prevent touchscreen powerdown)?
so long as programming is done Java or userspace level, there is no concurrency issues - it should be managed at the kernel level. but at userspace there is also security restriction at the Dalvik VM level - it will impose the level of access and what you can do with the hardware in your Java Apps (be it running as background jobs etc).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.