1.AndroidManifest.xml中注册一个receiver,并且获取开机启动权限permission
2.建立一个名为LaunchReceiver的Broadcasteceiver类,启动相应的服务。
package project.observe;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;//设置开机启动Servicepublic class LaunchReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Intent myIntent = new Intent(context, MyService.class); context.startService(myIntent); }}