Service is an application component. Service which runs on background for a long time without a help of user interface. Service can even start up from another application component like Activity,Broadcast receiver and it will continue to run in the background even if the user switches to another application. For example, a service might handle network transactions, play music, perform file I/O from the background. Android has two type of service namely 1.Service 2.IntentService Difference between these two services are Service run on main UI Thread, while IntentService creates a worker thread and uses that thread to run the service. IntentService creates a queue that passes one intent at a time to onHandleIntent(). Service want to stop manually by stopService() and stopSelf(). Meanwhile,IntentService will stop automatically after the completion of work. IntentService implements onStartCommand() that sends Intent to queue and to onHandleIntent(). Create Android P
Comments
Post a Comment