0

I am doing background process in my android application for that i used service.In iphone i use appdelegate for the background process.

My question is any other alternate methods to do the background process in andorid? If so which will be the best one?

Thanks.

sd33din90
  • 1,290
  • 1
  • 10
  • 23

1 Answers1

0

To perform background process in Android you have 3 best options:

1) Thread

2) Service

3) ASYCN task

All these three are for the same purpose for which you are looking.

To stop Thread:

In general, you don't forcibly stop threads because it's dangerous. You set a flag that tells the thread in question to exit from it's thread loop under controlled circumstances.

Your thread loop looks something along these lines:

void run() {
  while (shouldContinue) {
    doThreadWorkUnit();
  }
}

How to Stop Thread:

Community
  • 1
  • 1
Sam-In-TechValens
  • 2,492
  • 4
  • 32
  • 66
  • Now Service is my first option to do my work.Because i am doing server listening process when application is running.am i correct? – sd33din90 Jan 05 '13 at 13:40
  • yaah, sure you can do that with service....even Thread is also a good option for this...As generally I use thread...!!! – Sam-In-TechValens Jan 05 '13 at 13:43
  • How to do background process with thread? When we interact with user interface the app will display ANR? – sd33din90 Jan 05 '13 at 13:47
  • When i want to moves out from server listening process for that i need to stop thread.How can i do that? – sd33din90 Jan 05 '13 at 13:51