File upload in background: thread/service/AIDL...?

by Mark Murphy » Tue, 02 Mar 2010 01:31:53 GMT

Sponsored Links

In which case, do the following:

Step #1: Implement your Service as a subclass of IntentService.
IntentService handles the whole background thread thing for you, so you
will not need an AsyncTask.

Step #2: Put your file-upload logic in onHandleIntent() in your
IntentService subclass.

Step #3: When you have something to upload, create an Intent that
identifies the service (e.g., new Intent(this, MyService.class);) and
put a string extra on it (via putExtra()) that contains the thing to upload.

Step #4: Call startService() with the Intent from Step #3.

Step #5: In onHandleIntent(), you are passed the Intent, so you can call
getStringExtra() to get the value and use it.

Step #6: There is no step #6. Your service will automatically shut down
when there is nothing more to upload, and it will be restarted
automatically if another upload is required.

Mark Murphy (a Commons Guy)  | 

_Android Programming Tutorials_ Version 2.0 Available!


Other Threads

1. Question about assets vs resources


I have many ogg files in my app(around 1mb worth). Currently I'm
loading them from my sdcard from a folder that i manualy coppied
across. For distribution of my app where should i put the oggs? I
tried adding them as resources(R.) but it seemed to make my app take
an age to load, would this happen? Is assets the way to go? if so has
anyone got an example of loading an oog from assets? i can't get it to


2. how to build adb.exe for windows.

    i want to modify the usb_windows.c in /system/core/adb and
recompile a new adb.exe to test our platform.
    but, when i use "make HOST_OS=windows", it failed.
    i use ubuntu 8.04 and i can build with "make HOST_OS=linux".
    does anyone know how to build my adb.exe?




3. Automatic launch of Virtual Keypad in first screen(launcher) of application

4. code for simple client server http communication

5. how to read values from the server using Http GET method

6. ContentProvider with openFile but empty _data

7. Problem HTC-Hero and Widget