Problem:
I want to write a process that will allow a user to take photos with the device and for those photos to then be uploaded to some listener in the cloud. The user should not have to do anything to initiate the upload, a background listener would just watch the folder and as long as it finds files in it it would upload them and delete them.
Two problems:
1) how to keep the program running in the background even after the user is no longer taking pictures (and if they reboot the device for it to wake up and finish the uploads, if any remain)
2) assuming the connection is spotty (as it always is) how to verify that a given image has completed its upload, and if not, to resubmit it.
I don’t need any code examples, I just would like opinions on the best strategy to get this implemented.
I was going to use Apache commons and just do an upload to a PHP, but am not sure what sort of error checking exists to take into account a connection drop mid file.
TIA.
Having essentially written this application several times on several platforms, I can tell you that it’s not a trivial endeavor. To tackle the first problem, you can create a Service that sits in the background and performs your uploads. In order for it to start up automatically, you can declare that it receives the intent android.intent.action.BOOT_COMPLETED in your manifest (you’ll need the permission android.permission.RECEIVE_BOOT_COMPLETED in order to make use of that). If you’re going to listen for stuff written out by the standard camera app, you can use registerContentObserver to listen for new stuff – beware, phones can have more than one place they stash photos!
For the second problem, have your webservice return information regarding the completion of the upload which your client can use to decide on retries.