package me.ele.demo.service; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.support.annotation.Nullable; import android.util.Log; import android.widget.Toast; public class StartService extends Service { public static final String TAG = StartService.class.getSimpleName(); @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Log.e(TAG, "onStart"); Toast.makeText(StartService.this, "start service success with data " + intent .getStringExtra(TAG), Toast.LENGTH_SHORT).show(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.e(TAG, "onStartCommand"); return super.onStartCommand(intent, flags, startId); } @Override public void onDestroy() { super.onDestroy(); Log.e(TAG, "onDestroy"); Toast.makeText(StartService.this, "stop service success", Toast.LENGTH_SHORT).show(); } @Override public void onRebind(Intent intent) { super.onRebind(intent); Log.e(TAG, "onRebind"); } @Override public void onTaskRemoved(Intent rootIntent) { super.onTaskRemoved(rootIntent); Log.e(TAG, "onTaskRemoved"); } @Override public boolean onUnbind(Intent intent) { Log.e(TAG, "onUnbind"); return super.onUnbind(intent); } @Nullable @Override public IBinder onBind(Intent intent) { Log.e(TAG, "onBind"); return null; } }