I recently had a chance to look at a GIF Keyboard (https://play.google.com/store/apps/details?id=com.riffsy.FBMGIFApp)
It is able to figure out what has been typed after '#' in whatsapp, messenger and other platforms.
I have been looking around and looking for a way to replicate that behavior.
I have been looking at the accessibility api of android. But how does one track what has been typed in by the user on the soft keyboard?
Custom keyboard like gif keyboard in android - Unlike this, i do not want to implement my own keyboard, rather it should work with the current keyboard.
Is there some kind of broadcast that i could listen to? Is this a feature of Whatsapp to allow the keys to be tracked or is it the OS?
Any help on this greatly appreciated.
PS: I know i should post solutions i have tried so far, but there has really been nothing substantial that i found after days of investigation.
I found a solution to this. I achieved this by using an accessibility service and calling event.getText to get the text in the currently focused EditText
public class MyKeyboardAccessibilityService extends AccessibilityService {
@Override
public void onServiceConnected() {
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
info.eventTypes = AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED;
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
setServiceInfo(info);
}
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
String text = event.getText();
...
}