package com.deepesh.startedserviceapp; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.TextView; public class MyIntentService extends IntentService { public MyIntentService() { super("MyIntentService"); //This restarts the service is the app is terminated. setIntentRedelivery(true); } @Override public void onCreate() { super.onCreate(); Log.d("Keyy","Oncreate executed " + "Thread : " + Thread.currentThread().getName()); } @Override protected void onHandleIntent(Intent intent) { Log.d("Keyy","This is from intent service." + "Thread : " + Thread.currentThread().getName()); for (int i=0;i<10;i++){ try { Thread.sleep(1000); Log.d("keyy","Counter : " + i); } catch (InterruptedException e) { e.printStackTrace(); } } } @Override public void onDestroy() { super.onDestroy(); Log.d("Keyy","OnDestroy executed " + "Thread : " + Thread.currentThread().getName()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)