Close

Android and Contacts Integration

A project log for Project Stark Framework

This is a YET ANOTHER attempt at an "Iron Man" Jarvis-like system

robweberrobweber 08/16/2016 at 18:570 Comments

One of the most convenient ways to interact with anything is to just do it right on your smart phone. Interacting with Stark via my phone was actually one of the first reasons for creating any sort of client library. Most of the functionality you'd want with an automated assistant like this is already built right into the phone; which is why a lot of companies put the assistant right in the phone and offload the processing to the cloud.

The Stark Framework was always meant to be more about personal automation than some sort of glorified phone based notification system. As I've written in other logs the goal of the Stark Framework has always been to aggregate information from other systems to provide event based automation and control. Other systems and libraries do things like SMS, lighting control, and media management far greater than I could just write up myself. The idea was to leverage those systems and get their data into a place where you can then feed it into other systems - thus linking them together. With this in mind the Stark Android app was always meant to be a client to interface with the system, rather than a component of the framework itself.

That being said there are some interesting things you can do with data from the phone, given that it's sort of the hub for all communications these days. Below is a short video showcasing the Android app and what it can do to interact with the system.

What is in the Video?

This video was made in my development environment running an Android Virtual Device. It's a bit slower but easier to test and screen capture than on my actual phone. The only component missing is the speech to text feature (which is arguably the most cool). You'll see the "recognizer not installed" message which is where you'd launch the built-in Google speech recognizer. Google is doing all the processing here and the result is then returned to the app to send as regular text.

As you'd expect the app can send commands and receive responses from the Stark server application. I tried to emulate a chat window type system, but I'm not very good at UI programming so it isn't super flashy. As with the other methods I've shown, this is user based so you need a login. You can also choose to send events from the phone to the Stark server. These events are:

These events are sent to the Stark server and can be used as the basis for Monitors and Triggers. A really basic example is that when I'm home I have a monitor that forwards all my SMS and Phone call events to my Kodi media center instances. Even if my phone is in another room I'll see "Text Message received from XYX" as a notification on my TV. I do the same with the low battery event. I often leave my phone around the house during the day, and knowing it's about to die is a useful notification. A more complex example could be a Wifi based Trigger. You could have a task set to happen at home based on when your phone connects to your home Wifi SSID. Since you can tap in to any other integration the Stark Framework has the Trigger could turn on lights, switches, music, turn on a computer, or send a text to someone else just saying "hey I'm home".

One other function of the Stark Android app is its integration with your phone's contacts. In the early days of the framework I wrote a lot of code that tried to integrate with various contact management systems. It occurred to me, once the Android app was working, that since your phone is already aggregating all these contacts; why not use that as the collection point instead? The app can send contacts from your phone to the Stark server, where they are stored on a per user basis.

The benefits to this are that suddenly Stark now has access to not only the Users configured in the system (which extend the Contact class anyway) but other contacts you might care about. The ContactManager class within the framework is available from any Module; so you can arbitrarily have the system pull from these contacts. You can setup the SMS module to text a specific contact by name, or just lookup a phone/email for you. Using the Notes attribute you can also define custom data about a contact. For instance, I like to add the Minecraft Username of my friends I play Minecraft with. When we play together I can, through integration with my Minecraft server, ask if "John" is online. It can lookup John as a contact, and then match his Minecraft Username to names that are currently logged in to the server. I'm working on examining the Minecraft server integration in my next post as it eliminates a lot of the cumbersome Minecraft commands by being able to talk to Stark in a "human" way, who in turn issues the background command.

Discussions