Last active
March 1, 2018 15:22
-
-
Save sharifulislam52/7a907db5ed3d2cf177f45d4ab192e461 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
/** | |
* create service | |
*/ | |
public class service_Name extends Service { | |
@Nullable | |
@Override | |
public IBinder onBind(Intent intent) { | |
return null; | |
} | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
} | |
@Override | |
public int onStartCommand(Intent intent, int flags, int startId) { | |
// when service start this method will run | |
return START_STICKY; | |
} | |
@Override | |
public void onDestroy() { | |
// if we call this method service will destroy | |
super.onDestroy (); | |
} | |
} | |
/** | |
* call service from activity | |
*/ | |
startService(new Intent(current_activity_name.this, service_Name.class)); | |
//service_Name, current_activity_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment