Add Wear Notifications to Android App

Posted by in Software

TL;DR: Use notification mechanism. Steps are: Create a WearableExtender:

Extend the notification mechanism:

Trigger the notification:

After reading various sources, I got my application to send notification to my watch using the code above. At the beginning, I thought the notifications weren’t sent. I thought I needed to enable wear in the manifest (which I did), but… notifications were sent, just the watch was on charging dock and was’t doing anything :(. To make sure things were OK, I’ve enabled vibration:

Note: You need <uses-permission android:name="android.permission.VIBRATE"/>read more

Android: Make Your Notification even Sticky-er

Posted by in Software

In my previous post, I’ve expanded things to make a notification sticky. This worked in my tests until yesterday, when I’ve found a new case where my notification would go away: < ol> Build an sticky notification as per the two previous posts Activate the notification – this will trigger the activity to be displayed on screen. The notification will remain shown Activate the notification again – this will make the notification go away, because the activity is already on screen < ul> I’ve tried triggering the notification in onCreate()read more

Android: Make Your Notification Sticky

Posted by in Software

Following my quest from the previous article, I realised that my app would not be in the foreground, like an email, browser or a game might be, but it would work without any GUI, using something like a cron job. This is all nice and lovely, but I’m not fond of applications doing stuff behind my back. I’ve seen in various applications that do something similar a pattern: there’s something on the screen telling me (the user) the application is running. That “something” is usually an icon on the status…read more

Android: Notifications with Custom Layout

Posted by in Software

In the previous entries, I have managed to display a notification and make it sticky. Now, since the app I’m developing is supposed to be visible mainly through this notification, I wanted to see if I can customise the actual content. Yes, I know there are options by default, like: Small and large notifications Add some buttons to perform actions However, I wanted to see if I can, for example, add some icons and buttons like Sonos notification does: It turns out that, with a bit of work and an…read more

Android: Display a Notification

Posted by in Software

One of the applications I’m thinking about I want it designed like the notification-based applications you see out there (Light Flow from reactle comes to mind). To be able to do this, I first need the app to display a notification on the device as a first step. The code to trigger a notification is pretty simple and you can find a lot of resources online with various options. To cover for a lot of cases, I ended up over-engineering the process a bit, in the sense that I’ve encased…read more