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. C to CPP conversion (or vice-versa) based on the package type having C or CPP.

Hi fadden,

my "libmyusecase" is having  *.c files and all my header files is with the C
linkage as below.

#ifdef _cplusplus
extern "C" {
#endif /* _cplusplus */

#ifdef _cplusplus
#endif /* _cplusplus */

And i am trying to call the API's part of these *.c in a package containing
*.cpp files. I get undefined reference error.

But when i make the *.c files of "libmyusecase" to *.cpp  and remove the C
linkage  in the header files i dont get the undefined reference error.

Thanks and Regards,


2. "Android Developers Group for Singapore and South East Asia" IRC channel is up

Dear developers from Singapore and from our neighboring countries,

We have set up our IRC channel at #CodeAndroid on
where our developers can discuss and help each other out in
development. Please do join us in our discussion. We will also be
offering support for the upcoming ITSC's CodeXtreme competition that
is coming up, so if you are a participant do stay tune to the channel.
Thank you.

Chua Zi Yong

If you do not have an IRC client, you can log in at


3. question about tabs at the bottom

4. ANN: using PMD static analyzer on Android projects

5. start android on top of moblin/ubuntu

6. Emulator (SDK 1.1_r1 for widndows XP) crash using emulator -data

7. Bus error when running 1.5 emulator