Created
July 5, 2018 17:28
-
-
Save shahrukhamd/60542dea9d066872503c985099aa57fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExampleService extends Service { | |
int mStartMode; // indicates how to behave if the service is killed | |
IBinder mBinder; // interface for clients that bind | |
boolean mAllowRebind; // indicates whether onRebind should be used | |
@Override | |
public void onCreate() { | |
// The service is being created | |
} | |
@Override | |
public int onStartCommand(Intent intent, int flags, int startId) { | |
// The service is starting, due to a call to startService() | |
return mStartMode; | |
} | |
@Override | |
public IBinder onBind(Intent intent) { | |
// A client is binding to the service with bindService() | |
return mBinder; | |
} | |
@Override | |
public boolean onUnbind(Intent intent) { | |
// All clients have unbound with unbindService() | |
return mAllowRebind; | |
} | |
@Override | |
public void onRebind(Intent intent) { | |
// A client is binding to the service with bindService(), | |
// after onUnbind() has already been called | |
} | |
@Override | |
public void onDestroy() { | |
// The service is no longer used and is being destroyed | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment