Just use a service to test for internet connectivity every so often, when there's internet connectivity just do whatever you need your app to do...
Hello Peter... Ok, I can schedule a service each, let's say, 30 seconds... but imagine:
- Running each 30 seconds will clearly spend more battery than a service called by push, for example.
- In an unstable connection, the time when service starts could not be the same time frame when the internet is available (this is very significant, for example, when I have to send a small message with a few bytes and only 5 or 10 seconds of connectivity could be enough).
- And finally, in messenger services like those that we manage here it's very common to have two users testing the messages efficiency putting two mobile devices side by side and checking how much time a remote system will spend to receive a message after internet connection... 30 seconds is A LOT in this cases. Of course that the use of Firebase Cloud Messages increases the response efficiency for incoming messages due the push function starting the services, but for queued outgoing messages I cant see other way instead of maintaining a foreground service while there is queue... and this is not good because I have reports from many users about the "dislike" of persistent apps notifications...
I'll study a little bit more and post here if I find new solutions.