Services and hangs on UI in Notification resolved | Techbirds
I am writhing this to inform all my mates that while doing multiple tasks that continuously updates the UI via notification etc. hangs the UI since there is a lock that threads apply on UI. so instead of doing it in Activity do it in a service that separates the life completely from the apps life .
Services do not go under pause which makes them totally different life than an Activity.
it continuously runs in background. now the question is if a service needs to provide update to the actions going on .
for that make the service foreground and alive and not giving OS any chance to free resources.
there is a graceful degradation of priority if long running services are there. for notification use sendBroadcast to notify the activity for a particular point to occur.
refer the documentation of developer.android…
in the activity , make a receiver object for the same intent and dont forget to register the receiver in resume() and unregister the receiver in pause().
On receive method must be implemented for the same to do any action regarding services when the above stated particular point occurs.
Service runs on main thread it has a process of its own so it consumes resources .
To optimize resources do the long running tasks in threads under services life..
Open for any discussion regarding same.
1,251 total views, 2 views today
Share this On