Android Service

一、在MainAcitivity界面启动Service  :

public class MyService extends Service
intent = new Intent(MainActivity.this,MyService.class);
startService(intent);

service 启动,先执行 MyService() 这个构造函数, 再执行 onCreate() ,然后执行 onStartCommand() 函数。

停止服务:
stopService(intent);  onDestroy()

绑定服务:
bindService(intent,this, Context.BIND_AUTO_CREATE);   MyService() ; onCreate();  IBinder onBind(Intent intent);  onServiceConnected() ; 

解除绑定:
unbindService(this);  onDestroy()
原文地址:https://www.cnblogs.com/z360519549/p/5812222.html