I was wondering if it is possible to intercept keyboard input on a global level on Android. For example a user types in text into an edittext (does not matter which application) I would like to access said text to check for certain words. Is this even possible with Android's security model (yes I am aware this kind of feature could be used for various wrong things too).
Thanks,
b3n
Not possible. Thst's a security hole. You're welcome to modify the android firmware though
Related
I was looking is there any possibility to force an app to use the Android native keyboard instead of a custom one (ie Swift keyboard).
Thinking in terms of security this could be an interesting topic in order to prevent loose of information through fake or malicious keyboards.
What do you think, any possibility to do that?
Thanks,
Regards,
AFAIK there is no possibility of enforcing the default keyboard, I've also found nothing about this in the OWASP Mobile Security Testing Guide.
I fear this is the reason why some applications provide their own custom keyboard for PIN/Code entry.
Another hint: if you use sensitive text fields you should at least disable auto-correct (and automatic learning of new words) for this field. Otherwise the password could be found in the autocorrect database (which was shared between users on older android versions).
Precondition : Accessibility Talkback on.
Problem : While typing in characters from soft keyboard into the edit text, the characters are announced twice.
(I think once by the keyboard and once by the edit text).
Problem: Sighted users don't understand/empathize well with the types of information that blind users need. They just use a keyboard with TalkBack on, without actually closing their eyes and experiencing it the way a blind or partially sighted user would.
Solution: Close your eyes and actually use the keyboard the same way a TalkBack user would. You will discover that there are actually two relevant pieces of information here. The key that you're going to select and the key that you've actually selected.
Real Solution: Let Android do its thing unless you REALLY know what you're doing. More often than not, well intentioned, developers just muck things up when they start trying too hard. Provide content descriptions for your non-text controls, hook up some nice data associations when necessary and otherwise leave things alone.
I would like to listen for a text-highlight event in the system not only in my app (i.e at least in chrome).
Is this possible folks and if yes can you please provide a sample implementation?
I found the answer here: How to develop an Android tool to be used for any text in any app
Is that possible?
Generally speaking, no, for security reasons.
In this specific case, you could create your own input method editor
(a.k.a., soft keyboard), which the user could elect to use, and you
could find out when the user selects text in an EditText. But writing
a good input method editor is not simple, and it will have no effect
on, say, text highlighted in a Web browser.
Can I use "The Clipboard Framework" to listen for text selection?
No.
I want to create a custom keyboard for my application. ie. consider a simple text input and when I click on that, I want a custom keyboard to appear. For ex : a dialler like keyboard, having keys 0-9 and then some custom buttons for my application. Is it possible to do that in android?
Yes, this is possible. There are two ways to approach this:
Create your own input method (keyboard) - here's an example on google of how this can be done: http://developer.android.com/resources/samples/SoftKeyboard/index.html - you'll then need to set this keyboard as an IME in your app.
Create your own view with a bunch of buttons to handle your own stuff. This won't be a "keyboard" in a true android way, but it would do everything you need for your app. I have seen apps that contain their own "keyboards" designed in this way.
In addition, keep in mind that even the basic android keyboard has several "versions" available: alpha, keypad, symbols, etc.
Which way you prefer to go depends on your specific needs, your development abilities and time constraints.
Create your own view with a bunch of buttons to handle your own stuff. This won't be a "keyboard" in a true android way, but it would do everything you need for your app. I have seen apps that contain their own "keyboards" designed in this way.
In addition, keep in mind that even the basic android keyboard has several "versions" available: alpha, keypad, symbols, etc.
Which way you prefer to go depends on your specific needs, your development abilities and time constraints.
I've been looking to create a custom keyboard for my application. At first, I started to look at the SoftKeyboard for the SDK examples, but reading the Android Developer Group led me to this post:
This is really not how the input
method framework is supposed to work.
An IME should be a generic input
facility, not for a particular
application. If you need some
app-specific input, you should build
it into your UI rather than pushing
it out to a generic IME.
How do I build an app-specific input within the UI? I mean, is there a way to extend the Keyboard app or something and use it only in my application?
Features needed for the keyboard:
Shift key to display some other keys
Special keys like square root or PI
etc.
PS: an ugly solution could be to make a table of ImageButton for example, but I wanted to make something clean.
I'm not really sure if there's a straight-forward solution to this (to that extent that it is even possible to understand the real reason behind the original question).
As is quoted in the original question:
If you need some app-specific input, you should build it into your UI
rather than pushing it out to a generic IME.
What is meant by that, is not that you within your app should try to build in such input features by extending or modifying the soft keyboard on the phone. There are so many different soft keyboards (and basically, the soft keyboard is just another app), since most phone manufacturers create their own version, and people download 3rd party keyboards (such as Swype or SwiftKey etc.), and I can't picture there being a way for you to "hack" into those to add a few buttons or whatever it is you want (which could also be a major security hole, another reason why it probably isn't possible).
What instead the above quote suggests, is that you have to create some other form of input besides the keyboard. One such example, and a very good one if I might add, is how the RealCalc Scientific Calculator looks:
Now this isn't open source, so I can only guess how the code looks like (but it shouldn't be too hard a guess either): in its simplest form, this is just a grid with lots of buttons. Each button handles the onClick event, which would mean performing some kind of action (changing the label on some other buttons, showing a menu, displaying some text in the upper label or whatever), and that's probably pretty much what's to it. And of course, the phone's soft keyboard is never displayed (since you don't need a keyboard with all those buttons (and also there aren't any input fields to write anything in)).
It all boils down to the already mentioned quote: If you need some app-specific input, you should build it into your UI. Or in other words: create buttons (and don't display the soft keyboard if you don't need it) and make things happen when you click them.
And just to have mentioned it: if you do want to create your own IME (which I strongly believe is not the case here), you should have a look at the following resources:
Onscreen Input Methods
Creating an Input Method
Soft Keyboard sample
In my humble opinion you should take a look at the beginning of reference about keyboard and keyboard view http://developer.android.com/reference/android/inputmethodservice/Keyboard.html and http://developer.android.com/reference/android/inputmethodservice/KeyboardView.html.
There you can see an example of defining keyboard using XML file. I think that this is what you are looking for.
As mentioned by #sebap123
Keyboard and KeyboardView class are the one you need to use,
Further, for Implementation, here is a quick detailed guide.