Android: Global Key Listener - android

I am writing an android app which will record the frequency and timestamps of when a user is using their keyboards (soft or hard) (Example: a parent checking to see if their child was texting during school by giving them timestamps and frequency of key presses). This wouldn't need to know what was being typed, just when something was typed. It would also need to function regardless of what app was using the keyboard.

This is not possible, except perhaps via custom firmware.

Related

Android application for creating aliases, needed functionalities

I would like to create an android application that will allow to define and use of aliases when entering text on the keyboard by the user in the entire system/where possible. Something like the "Texpand - Text Expander" application.
For example:
If we write an SMS, after typing 'wu', a option appears above the keyboard with the option of clicking and expanding this shortcut to the one previously defined in the application, e.g. 'What's up?'.
How can we keep an eye on user keyboard's input from other components and constantly communicate with our aliased application? After installing Texpand, I can see that it uses Services, but I haven't found a way to constantly watch the inputed keyboard's text and synchronize it with the application.
Should I use WindowManager for the option that appears after entering the alias or are there any other methods?
Stack: Kotlin&Compose
I've learned about services, but is there something more needed?

How to store the number of time each key pressed in android?

Sorry for asking this type of a question. I'm a newbee to android and i have this idea to develop an app to detect stress based on dwell time and flight time of the keys. Is there a way to get these values through a background service ? I'm aware about creating an intent service and using alarmManager to run this service only during a certain time of the day. but the core part is missing as to get dwell time and flight time of keys pressed in the keyboard.
Is there a way to get these values through a background service ?
No.
get dwell time and flight time of keys pressed in the keyboard
Write your own input method editor. Then, convince users to use it.
Bear in mind that many existing input method editors actually use long-press events for different keys (e.g., long-press U to get 7 without having to switch to a separate set of keys). Other input method editors use gestures, where the finger does not leave the keyboard. In other words, the concepts of dwell time and flight time — originally developed for physical keyboards — would have to be revisited for soft keyboards anyway.

Is it possible to keep track of record of user interaction from background in android?

I am working on an android application which can be used to capture the sequence of user interaction on android device. Starting from when the device is powered ON.
This is to be done by an application, based on the users event a script (Comma (,) delimited text format) will be generated which can be used further to played back the records of events.The application must have various button to start, pause, stop button for recording, script creation should also work according to button pressed.
Is it possible to keep track of record of user interaction from background in android?
I didn't get anything about this. Any help or suggestion is well appreciate.
The application you are describing is a KeyLogger. Unless you have root permissions you cannot do this. If you could it would represent a huge security gap in android. It would allow any app to capture credit card numbers, passwords, email address, etc...
Your only options are to use root privileges or write a custom android keyboard; however, that will only let you record keystrokes when your custom keyboard is used.
A better question is what are you trying to do, as there is probably a better way to acheive what you want.

Android Dev: Getting key events from onscreen (soft) keyboard

I'm developing an Android program to analyze a user's text input and measure typing speed, error rate, average key presses to enter a single character. By doing so, I can compare characteristics of different input methods. To do this, I need to count and record all key presses made by the user during the text entry process.
For example, a user using a basic qwerty keyboard would have to press at least one key for each letter. However, a user using a keyboard with word completion would need to press fewer keys. But how many key presses are made (on average)? Does word completion actually improve typing speed? These are the questions my program will help answer.
Reading other posts, I know that (by default), onscreen keyboards don't send key events for all key presses. Physical (hardware) keyboards do, but most mobile devices don't have a physical keyboard. I also know that I can implement a TextWatcher to detect when a letter is typed in an EditText field. However, some IMEs might require the user to press a sequence of keys to enter a single letter (or word). I need to handle the intermediate key events (i.e., by counting and logging key presses).
My question: How would I capture every key press event from an IME (even events that don't trigger a typed character) without modifying the IME's user experience (e.g., auto completion, word prediction, T9 disambiguation, etc.)? Is this even possible?
Thanks in advance for your time.
Is this even possible?
Only by writing your own IME, AFAIK, or getting the source to an existing IME and instrumenting it.
did you try to listen for TouchEvents?
did you try to use onKeyPreIme() from View class? with this one you can catch key presses before they are consumed by the IME

Key event handling process

I'd like to know how the key event is handled in Android platform.
From 'when user type key 'a' on software keyboard',
To 'view draw the character 'a' on itself'.
Probably, the key event is generated by IME,
And it will be sent to parent view,
Finally, view(such as EditText) displays chracters.
Please somebody explains about these entire key event handling process.
Take a look at this article: http://developer.android.com/resources/articles/creating-input-method.html
Basically, you can either manually send KeyEvents or you can manually edit and commit text around the cursor in the application's Input View.
These are all done via your IME's InputConnection.
OnKeyListener and OnKeyDown do not get called, as you have discovered, when using a software keyboard. They only get called when using a hardware keyboard, which many Android devices don't even have.
I assume what you are trying to do is capture key events as they are occurring in an EditText area. Your best bet in this case, in order to handle both software keyboard input and hardware keyboard input, is to register a TextWatcher via the addTextChangedListener() method.
Note that on phones with Android 2.1 and later, such as the Nexus One, people have the option of using speech recognition to input text into your EditText instead of typing the text. When they do that you may get full words, or even full sentences, entered all at once. So you need to check the entire contents of the EditText field when there is a change to the contents.

Categories

Resources