Android services – lost messages problem

When Android runs a service it’s necessary to bind it to a application, otherwise the operating system will clean the service up. This is useful because it reduces the waste of resources. Ireckon uses a wearable listener service which means that once it has interpreted the message from the watch and sent it back, the android garbage system destroys it quickly – but not quickly enough.

The problem for Ireckon was that if a message was sent from the watch to the phone whilst the OS was in the process of destroying the service then the message would be lost.

The solution to this was to check for a response from the phone. If there wasn’t a response it was necessary to back off for a few seconds and then send the message again, repeating this if necessary.