Search code examples
androidbackground-process

How do you connect to a server in the background when your app is closed?


I need to sync data with my app and server as soon as possible.

If my app is open and the user has an internet connection, this is easy.

In my current implementation, if the user has no internet, interacts with my app, and then closes it, the app and server do not sync until the app is re-opened.

Is there a way to sync data with my app and server when the user has an internet connection but has not opened the app? links are appreciated!


Solution

  • You can use GCM Network Manager to carry off network related tasks in background. You can implement both periodic and one time tasks using this. This API serves exactly what you want.