I would like to know how it can be detected when a notification is received, I understand that it can be done using AccessibilityService, but I can not get it to work, this is the code that I have in my service:
public class MyAccesibilityService extends AccessibilityService {
@Override
public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
Toast.makeText(this, "Evento de:" + evt.getPackageName(), Toast.LENGTH_SHORT).show();
}
@Override
public void onInterrupt() {
}
}
I have also declared the service in the manifest file as follows:
<service android:name=".MyAccesibilityService" android:enabled="true">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data android:name="android.accessibilityservice"
android:resource="@xml/accesibility" />
</service>
And this is the meta-data xml code
<accessibility-service
android:accessibilityEventTypes="typeNotificationStateChanged"
android:notificationTimeout="100"
android:accessibilityFeedbackType="feedbackAllMask"
xmlns:android="http://schemas.android.com/apk/res/android" />
I hope you can help me!