You not only need to do it in a Service, but you need to launch a separate thread. The class that can do both for you is IntentService.
BTW: the Android documentation on both of these is a little misleading: when the Service docs talk about 'background', they mean something a little different than 'background' in the phrase "background thread/task". They mean that a Service does not have the UI foreground. But by default, it is still in the main UI thread. That is why you need to either spin off your own background task thread or use IntentService to do it for you. You could also use AsyncTask, but there are subtleties about using that with a Service. In particular, if you want to avoid tight coupling between the main Activity's hosting process and the Service, you should stick with IntentService. Should you choose the AsyncTask route, check out https://github.com/commonsguy/cw-android/tree/master/Service first. On Feb 7, 7:40 pm, balu <balu.balachan...@gmail.com> wrote: > Hello everyone... I am working on an email application. I connected to > the pop3 email server using sockets. But i donno how do i run the > socket programming background. I have gone through some internet > stuff, and there i came to know that i should use services. Can anyone > tell me how do i do that? or is there any other way? > > And also once i login, i need to be able to access the background > service by all the other activities? > > Thanks in advance. -- 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