In my last post I explained why I couldn’t extend third party notifications with my app and at some point I say: “I can’t extract the basic information from the notification and recreate a basic version on the watch. There are certain “hacks” which do attempt to do this but they only work on some Android versions.”. This was true when using the NotificationListener, but my supervisor found out that when using a full AccessibilityService to detect new notifications, it is possible to get some information from the Notification object.
So given this new option, I tried adapting the Notification again. Several apps already offer some smart watch actions and I didn’t really want to lose them in exchange for a reminder button. So I tried to add a reminder button without losing the original actions. First of all, when trying to implement this, it’s obvious Android did not intend for this to be possible, resulting in very inconsistent behavior. The only way to do this is create a new Notification and extend it using the original Notification object.
As a result I got somewhat of a copy of the original notification with my action added to it. Side effects include but are not limited to:
- Actions from the original notification might disappear,
- Icons from the original notification get switched up or disappear,
- Background image of the notification might be removed
- Content of the notification is limited. Any long notification will get cut off,
- If one app generates several notifications, the first copied notification will somehow lose it’s content when the next notification is posted.
But maybe the most important problem is that the only way to store the complete Notification object, to post it again later for the reminder, is in a static variable. Unfortunately Android does not guarantee the persistence of static objects during runtime. As I’ve mentioned the Notification object isn’t Serializable, meaning I can’t save it to persistent memory either.
I will keep the “functionality” as-is for now and do a quick evaluation on whether users would still like this option or if it would just be a nuisance.