Stopservice onbind called when any component calls

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ice Lifecycle •  Service lifecycle methods –  They are public, not protected: void onCreate() void onStartCommand(Intent intent) void onBind() onUnbind() void onDestroy() COMP 4521 (Muppala) Interprocess Communication 4 Service Methods •  onStartCommand() –  Called when any component calls startService() –  Need to explicitly stop the service by calling stopSelf() or stopService() •  onBind() –  Called when any component calls bindService() –  Need to provide an interface that clients use to communicate with the service, by returning an IBinder •  onCreate() –  Called when the service is first created •  onDestroy() –  Called when the service is destroyed –  Must clean up any resources such as threads, registered listeners, receivers etc. COMP 4521 (Muppala) Interprocess Communication 5 Service •  Service runs in the main thread of the process –  If performing long- running opera0ons, create a separate thread within the service •  Service or background thread? –  Use service when you expect the opera0on to con0nue in the background even when the user is not interac0ng with the applica0on –  Use background thread from the...
View Full Document

This document was uploaded on 03/12/2014.

Ask a homework question - tutors are online