Im trying to create an app which includes chrome visited site logger function
here is my AccessibilityService
class CoreService : AccessibilityService(){
override fun onInterrupt() {
return
}
var TAG = "app:"
override fun onServiceConnected() {
Log.i(TAG,"Connected")
}
override fun onAccessibilityEvent(event: AccessibilityEvent) {
Log.i(TAG,"onAccessibilityEvent")
onChromeActivity(getRootInActiveWindow())
}
fun onChromeActivity(nodeInfo: AccessibilityNodeInfo) {
var result = "|"
var arra = nodeInfo.findAccessibilityNodeInfosByText("http");
for (i in 0 until arra.size) {
result += "\n" + arra.get(i).toString();
}
Log.i(TAG,"result: $result")
}
}
xml config
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityFlags="flagDefault|flagIncludeNotImportantViews|flagRequestTouchExplorationMode|flagRequestEnhancedWebAccessibility|flagReportViewIds|flagRetrieveInteractiveWindows"
android:accessibilityEventTypes="typeWindowStateChanged"
android:accessibilityFeedbackType="feedbackGeneric"
android:notificationTimeout="0"
android:canRetrieveWindowContent="true"
android:packageNames="com.android.chrome"
android:description="@string/desc"/>
So far im getting this logcat
2018-11-07 17:08:15.516 19631-19631/com.jmg21.omgi I/app:: result: | android.view.accessibility.AccessibilityNodeInfo@8000ccce; boundsInParent: Rect(0, 0 - 681, 131); boundsInScreen: Rect(115, 71 - 796, 202); packageName: com.android.chrome; className: android.widget.EditText; text: https://www.google.com; error: null; maxTextLength: -1; contentDescription: null; viewIdResName: com.android.chrome:id/url_bar; checkable: false; checked: false; focusable: true; focused: false; selected: false; clickable: true; longClickable: true; contextClickable: false; enabled: true; password: false; scrollable: false; actions: and so on...
The Problem is:
1. I only get this at one time if i try to go to other site nothing happen
2.I can not get the url
Please help and Thank you in advance!