Issue
AccessibilityService getting disable automatically after some time every after granting autostart permission in vivo,oppo devices.
Manifest.xml
<service
android:name=".Service.MyAccessibilityService"
android:label="@string/app_name"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
</service>
accessibility_service_config.xml
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFlags="flagDefault"
android:accessibilityFeedbackType="feedbackGeneric"
android:notificationTimeout="100"
android:canRetrieveWindowContent="true"
android:canRequestFilterKeyEvents="true"
android:settingsActivity="" />
MyAccessibilityService.class
public class MyAccessibilityService extends AccessibilityService {
@SuppressLint("WrongConstant")
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
try {
AccessibilityNodeInfo rootNode = event.getSource();
if (rootNode != null) {
if (event.getEventType() == AccessibilityEvent.WINDOWS_CHANGE_REMOVED) {
Log.d("tah", "event: " + event.getText().toString() );
//accessibilityEvent.getText().toString()
// will give all text which user typed in input box
}
int count = AccessibilityEvent.obtain().getRecordCount();
Log.i("TAG", "count=" + count);
for (int i = 0; i < count; i++) {
// AccessibilityRecord の取得
AccessibilityRecord record = AccessibilityEvent.obtain()
.getRecord(i);
Log.i("TAG", "className=" + record.getClassName());
// AccessibilityNodeInfo の取得
AccessibilityNodeInfo node = record.getSource();
if (node != null) {
Log.i("TAG", "parent=" + node.getParent().getClassName());
int childCount = node.getChildCount();
for (int j = 0; j < childCount; j++) {
Log.i("TAG", "child="
+ node.getChild(j).getClassName());
}
}
}
}
} catch (Exception e) {
Log.e("tag", "Exception: " + e.getMessage());
}
}
@Override
public void onInterrupt() {
Log.e("tag", "onInterrupt: " );
}
}
this is the issue.
Solution
Go to App info, then turn on Autostart
also allow no battery restrictions
Answered By - Manoj Perumarath
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.