Sending Android Notifications to Desktop using Amazon Web Services (AWS)

Was feeling a little bored, so I decided to throw together an application to forward all notifications from my Android phone to my desktop.

The Basic Process

  1. Android App – Create an Android application that hooks into the phone as an accessibility service. This service then listens for TYPE_NOTIFICATION_STATE_CHANGED events and sends a message to Amazon SNS (Simple Notification Service). This┬áleveraged┬áheavily off the AWS SDK for Android.
  2. Amazon SNS Topic – This topic receives the message and contains one Amazon SQS (Simple Queue Service) queue as a subscriber. (As a side note, I originally didn’t use Amazon SQS, but instead forwarded any SNS notifications to an email address. Emails from the SNS topic were then kept in a specific label which was monitored using IMAP IDLE. However, I had some problems with responsive and speed with this, so I decided to utilise SQS instead.)
  3. Amazon SQS Queue – This queue is set to keep messages for only 5 minutes (this prevents old alerts from showing up on your desktop.) Similarly, make use of the long-poll option so that you get almost-instant response from a polling client without having to constantly hit the server with requests for new messages.
  4. C# SQS Notifier – This is a basic C# program that polls the Amazon SQS Queue for new messages. If a new messages exist, it triggers an alert to Growl (which I used so I didn’t have to bother styling any sort of notifications or alerts.) This leveraged off the AWS SDK for .NET and the Growl .NET libraries.
  5. Growl – Growl for Windows to display alerts in a nice, styled manner.

Android Application – SNS Notifier

This was a lot simpler to build then I had originally expected. Especially after I found this article on the web.

SNS Notifier Android

Amazon SNS Topic

This is fairly simple to do. Create a topic and make sure your IAM user has permissions to access it.

Amazon SNS

Amazon SQS Queue

This also is fairly simple. Create a SQS queue, add permissions for your SNS topic to send messages to it and then ensure your queue settings are appropriate. Also, make sure your IAM user has permissions to access this.

SQS

C# SQS Notifier

This was a very small, custom C# application that simply runs on your desktop and fires off alerts to Growl when there’s something in your Amazon SQS queue.

SQS_Notifier

Growl

This is what the final end product looks like! :)

Growl

One thought on “Sending Android Notifications to Desktop using Amazon Web Services (AWS)”

Leave a Reply

Your email address will not be published. Required fields are marked *