package ko.serviceexample;

import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;

//>> also need to add <service> to manifest
public class MyService extends Service {
    final String TAG = "MyService";

    public MyService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    //>> entry point of stand-alone service
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d(TAG, "onStartCommand");
        Log.d(TAG, "downloading....");

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Log.d(TAG, "download is completed");
            }
        }, 3000);

        Log.d(TAG, "onStartCommand is going to finish");
        return START_NOT_STICKY;
    }

    @Override
    public void onDestroy() {
        Log.d(TAG, "onDestroy");
        super.onDestroy();
    }
}

@@ -759,24 +759,113 @@
 completed%22);
+%0A%0A                //%3E%3E following code will stop the service%0A                //stopSelf();
 %0A           

update Service Example