android - Where to create own thread, Inside service class or Inside the activity form where we give call to the service -


One service in Android runs in the main thread of its hosting process, I want to know if I want to make my own Thread, where to make it, within the service class or within the activity, the way we call the service ..? Thanks in advance

Your activity should start your service, then start your thread inside the service if If you put your service launching code in a thread, then whatever the thread does, the thread starts in the background, but the service (and as a result, the code you want to run in the background) will still run on the main thread.

If you want to do some continuous work If not shish, I would suggest using one. All thread handling and service cleanup with an IntentService are done for you.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -