I have this application running on adnroid devices. I need to respond to a WhatsApp notification (since I donβt know another way) and get my application to notify the user of a new message. Our users are people with disabilities, so we need to provide a slightly simpler interface. To receive the notification, I created an accessibility service with the packet filter "com.whatsapp". Everything works fine until we reinstall our application. After reinstalling, we again need to bind the service manually (which is very problematic). Any help would be greatly appreciated!
This is the "onAccessibilityEvent" code:
@Override public void onAccessibilityEvent(AccessibilityEvent event) { Log.d(TAG, "NotificationService event"); if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { String packageName = event.getPackageName().toString(); if(packageName.equals("com.whatsapp")){
//Utils.showLargeToast (getApplicationContext (), "New WhatsApp Message"); }}
accessibilty_service_config
android:packageNames="@null" android:accessibilityEventTypes="typeNotificationStateChanged" android:accessibilityFlags="flagDefault" android:accessibilityFeedbackType="feedbackGeneric" android:notificationTimeout="100" android:canRetrieveWindowContent="false" android:description="@string/description_that_shows_on_the_accessibility_page" />
and the manifest part
android:name=".NotificationService" android:enabled="true" android:exported="false" android:label="WhatsApp Monitor Service"> <intent-filter> <action android:name="android.accessibilityservice.AccessibilityService" /> </intent-filter> <meta-data android:name="android.accessibilityservice" android:resource="@xml/accessibility_service_config" />
Thanks in advance!
source share