Do I need a thread in a boot_completed and startForeground started service?
I'm starting my service with the BOOT_COMPLETED broadcast and then bring it to the fron开发者_如何学Got with startForeground. Using it in a closed system, so it won't bother any other apps. Anyhow, I have three questions that are pretty similar to each other :-) , they are:
I usually make a thread inside my services, but do I need to do that in this case? Which thread is it blocking sins it's starting at boot-up? The UI-thread?
If I start a service with startForeground and I start a thread in that service, will the thread also be on foreground?
Will every service/activity that I start from the service (that's on foreground) automatically also be on foreground?
Thanks!
1.) Activities and services ALWAYS run in the UI thread.
2.) Threads have no notion of foreground or background. They're not tied to your activity, they're tied to your process.
3.) What do you think foreground means? All that does it make it a slightly higher priority for android to keep alive if it runs out of memory.
精彩评论