I have been trying to find some resources in order to build a Keylogger Android application for an accessibility research project on the Android platform (APILevel 17).
The Interface of the application would be a simple "EditText" field where the user types using the virtual onscreen keyboard [After selecting the required keyboard from the Input Settings].
I aim to create a Keylog database for my application (with an SQLite DB because I'm familiar with that, but a simple csv file DB would also work well! :) ) which looks like the following: (Illustration)
Hence I need to log each character on a new entry as soon as it is typed, along with the timestamp. I have been trying to expriment with the "TextWatcher" Class
EditText KeyLogEditText = (EditText) findViewById(R.id.editTextforKeyLog);
TextWatcher KeyLogTextWatcher = new TextWatcher() {
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
{ }
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3)
{ }
@Override
public void afterTextChanged(Editable arg0) {
// TODO Log the characters in the SQLite DB with a timeStamp etc.
// Here I call my database each time and insert an entry in the database table.
//I am yet to figure out how to find the latest-typed-character by user in the EditText
}
My Questions are:
- Is this the Right way of Implementing this?
- Can I obtain Exactly ONE character that is typed along with the time and insert it into the SQLite DB which I can later obtain and analyse??
- Or Would the onKeyUp Method be more useful? [I have not used tried method yet, So it would be great if someone could point me towards using this to build a keylogger if that's simpler!]
*Thanks in Advance to anyone who can help me in any way!
Adit*