package net.wequick.example.small.appavailable_if_stub;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;

/**
 * Created by galen on 2016/11/4.
 */
public class MyService extends Service {

    private static final String TAG = "MyService";

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i(TAG, "onCreate");
    }

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

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

@@ -127,21 +127,74 @@
 roid.os.
-IBind
+Handler;%0Aimport android.os.IBinder;%0Aimport android.os.Loop
 er;%0Aimpo
@@ -252,16 +252,20 @@
 oid.
-util.Log
+widget.Toast
 ;%0A%0A/
@@ -363,45 +363,19 @@
 ate 
-static final String TAG = %22MyService%22
+Handler mUI
 ;%0A%0A 
@@ -454,140 +454,586 @@
     
-Log.i(TAG, %22onCreate%22);%0A    %7D%0A%0A    @Override%0A    public void onDestroy() %7B%0A        super.onDestroy();%0A        Log.i(TAG, %22onDestroy%22
+mUI = new Handler(Looper.myLooper());%0A        mUI.post(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                Toast.makeText(getApplicationContext(), %22MyService is on!%22, Toast.LENGTH_SHORT).show();%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @Override%0A    public void onDestroy() %7B%0A        super.onDestroy();%0A        mUI.post(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                Toast.makeText(getApplicationContext(), %22MyService is off!%22, Toast.LENGTH_SHORT).show();%0A                mUI = null;%0A            %7D%0A        %7D
 );%0A 

Add toast on server start and stop for sample