File Upload interruption
Currently i have an application where an activity calls a service which sends a file to a server.开发者_JS百科 This is working fine..However, i was wondering does anybody know what happens if the internet connection is interrupted. Will the service run again when the connection comes back...Or is there something i need to implement to do this? If so how and what etc? thanks
The service will not run again when the connection comes back unless you add logic to do so. I'd recommend using a success flag to determine if a file was uploaded correctly, and if it wasn't due to an error (such as an interrupt), then you start the upload over again.
Perhaps alerting the user that a file upload has failed would be the best route to take, that way he/she can decide if its worth another try. This would also help keep your app from spiraling out of control while endlessly uploading a file to a server (although you could add a variable like maxNumberOfTries to avoid this).
精彩评论