Question

I have a running Android app, which sends data to a server. If the device is not connected to the internet, it should be possible to save the data temporarily on the device. If the device retrieves the connection, it should send the saved data to the server. Even if the app is closed.

My question is, how to create a "listener" which listens on the internet connection? This mechanic should work like WhatsApp. In WhatsApp you can receive messages, even when the app is closed.

I've looked a bit around....could this be a Widget? And if it is one, how to not display it on the Home screen? I don't need to display any information there.

Était-ce utile?

La solution

You can register for changes to connectivity by following the instructions at Monitor for Changes in Connectivity. When you hear that the phone has connectivity, send your data.

Sorry, I don't know enough about widgets to advise whether they'd be a good fit here.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top