I do not know about getEventText(event)
but if event.getText () works but not all applications give you the text you want,
Test Logear the result
To check strings in Java you should not use str1 == str2
but str1.equals(str2)
The full text does not seem to be that "device management" if not a part so it uses the contains function
Try something like this:
if(event.getPackageName().toString().equals("com.android.settings o la app que quieres capturar")){
String text = event.getText().toString();
Log.d("AppEjemplo",text);
if (text.contains("la administración del dispositivo") ){
Metodo();
}
}
You can also filter by classes
In this for now if the method works event.getText ()
if (event.getClassName().equals("android.app.AlertDialog")) {...
For other applications you have to go into the controls to get the text of each component. Ex:
AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
final AccessibilityNodeInfoCompat source = record.getSource();
StringBuilder sb=new StringBuilder();
private void logControls(AccessibilityNodeInfoCompat source, StringBuilder sb) {
if (source != null) {
for (int i = 0; i < source.getChildCount(); i++) {
final AccessibilityNodeInfoCompat currentSource = source.getChild(i);
if(currentSource.getClassName().equals("android.widget.TextView")){
sb.append(currentSource.getText()+" ");
}else if(currentSource.getClassName().equals("android.widget.EditText")){
mediatekEditText=currentSource;
}
logControls(currentSource, sb);
}
}
}