On 06/13/2010 03:46 PM, tarek.attia wrote:
> 
> I have a question what to Use ,Service Or Thread,as both run in the
> background

There is confusion here, because you are referring to two different meanings of
the word "background".

A thread, in Java but also in many other languages, allows for parallelization
within a single program/process, that is: doing several things at the same time.
If your program has a GUI and needs to do something heavy then you need to do it
in the "background" and thus within a separate thread, to avoid freezing the UI.
But this thread will terminate when your program terminates.

A service, in Android, is something which runs even when the application is not
in the foreground, that is: it continues to run when the user leaves your
activity and returns to home, or when the phone goes to sleep. If you don't need
this then you don't need a service.

As you may see, "background" here means something quite different, because a
service never runs in a dedicated /thread/. By default it runs in the main
application thread, and may optionally run in a separate /process/:
http://developer.android.com/intl/fr/reference/android/app/Service.html

--
  Olivier

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to