Posts

Showing posts with the label Whatsapp DashClock Extension

NotificationListenerService and a Whatsapp extension for Dashclock

Image
Android 4.3 (API 18) introduced NotificationListenerService . In this post I'll talk how to use this API, and I'll show how an app can observe the stream of notifications with the user's permission. It is very easy to use a NotificationListenerService. First of all you have to extend NotificationListenerService and implement onNotificationPosted() and onNotificationRemoved() methods public class WhtsNotificationListener extends NotificationListenerService { @Override public void onNotificationPosted(StatusBarNotification sbn) { //.............. } @Override public void onNotificationRemoved(StatusBarNotification sbn) { //.............. } } Then you must declare the service in your manifest file with the BIND_NOTIFICATION_LISTENER_SERVICE permission and include an intent filter with the SERVICE_INTERFACE action Finally user must enable your service. Without t...

How to write a DashClock Extension: Whatsapp Extension example

Image
After BatteryExtension and DialExtension , now I tried to write an unofficial Whatsapp Extension for DashClock . It was not so easy... WhatsApp does not expose an API or official ContentProvider and therefore the only idea I had was to listen for status bar notifications. It requires you to enable a Accessibility Service to work. I don't like this way, because it needs relatively deep/dangerous permission authorizations. At present, I would't install an application that requires this type of authorization. With these permissions, an app can listen for all notification from all apps... You can specify which packages you want to listen to and only listen to those package, but users don't have visibility of this information . It would be a good idea if in the next version of Android this information was available. You can listen for status bar notifications by using AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED . We are going to write our WhtNotificati...