Skip to content Skip to sidebar Skip to footer

Http Post Delayed Until Online

The code I currently have submits data successfully to a database when there is a network connection. My app is one that would be used outdoors, frequently in places were cell serv

Solution 1:

Should I create a service that is run if there is no connection that is alerted when a connection is available?

Yes. Use an IntentService to handle all network requests. When an Activity wants to upload/download anything, it passes its request to the IntentService. If there is no network connection, the request is queued and the IntentService terminates itself.

Also create a BroadcastReceiver registered in the mainifest which 'listens' for network connectivity changes. If the change is to a 'connected' state, it should start the IntentService which processes any queued network requests and again self-terminates.

It's efficient and works well in my experience.

Post a Comment for "Http Post Delayed Until Online"