Intent Service Class sample
public class MyIntentService extends IntentService { public static final String Somevariables = "somevalue"; public MyIntentService() { super(MyIntentService.class.getName()); // you can give any string but it is good practice to giving classname } @Override public void onCreate() { super.onCreate(); //--some code -- } @Override protected void onHandleIntent(Intent intent) { //you can retrive intent extras String msg = intent.getStringExtra(EXTRA_KEY); //--actual backgroung code gos here -- } }
Add service in manifest also
<service android:name=".MyIntentService"/>
ref: https://developer.android.com/training/run-background-service/create-service.html