方法来自网上,只作收集整理,以方便自己查询
1、提升服务的优先级 <intent-filter android:priority="1000">
2 、application标签中添加android:persistent属性
3、在service中重写onStartCommand方法, START_STICKY是service被kill掉后自动重写创建
return super.onStartCommand(intent, START_STICKY, startId);
4、 public void onDestroy() {
Intent ReIntent = new Intent();
ReIntent.setClass(this, MyService.class); //销毁时重新启动Service
this.startService(ReIntent);
}