Subscribe not responding during sleep

Greetings everyone,

This is my first post on the forum and my first time using a Particle device so I apologies for any mistakes I may make.

I am working on creating a custom Android app using the Particle SDK. I have been able to get all but one of the functions I need to work. I am able to subscribe to events from my Particle devices and publish responses back to the devices from my Android app. However, one key feature I haven’t been able to figure out yet is subscribing to events and then waiting for long periods of time before the event is received. The app needs to update its values when it receives the data from the Particle devices. This does not happen at regular intervals because certain conditions need to be met before the Particle device will send the data. I have done a fair bit of testing and determined that the problem is that when the phone goes to sleep, Android seems to be closing the connection the subscribe function has with the cloud.

Has anyone had success creating an Android app that can subscribe and keep listening during sleep?

Any help is greatly appreciated.

Hi and welcome to the Community!

I have no previous experience in what you are facing, but I’ll try to connect some dots from other apps.

Could it be that the way other Android apps avoid getting killed by the Android OS by setting a permanent notification, or a service that runs in the background?

From a Reddit post here about Taskers permanent notification:
When the monitor is running in the foreground, Android demands that it place a notification in the status bar. If the notification is annoying, you can disable this setting to remove the notification and see if the monitor service remains reliable.

Another example: Tasker

If this does not work, I would look into a push notification like this via Firebase Cloud Messaging.
There is a wonderful Google-Particle integration that can help you get there.

Hi @gusgonnet

Thank you for taking the time to respond to my question. I really appreciate it. Firebase does exactly what I’m looking for and works great!

Thank you again,

1 Like