I have written a simple code that Toast a message whenever the user types a particular word, for example, "help" and then it Toast a message
public void onAccessibilityEvent(AccessibilityEvent event) {
switch (event.getEventType()) {
case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
String string = event.getText().toString();
if (string == "help") {
Toast.makeText(getApplicationContext(), "we are here to help", Toast.LENGTH_SHORT).show();
}
I think the problem here is in the string as it is logging unnecessary words also as user types, is there any way how we can initialize the string for that particular word?