1).监听一个开机启动的Broadcast广播
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//do something
}
}
2). 在AndroidManifest.xml中注册这个Receiver来监听系统启动事件
<receiver android:name=".service.BootReceiver">
<intent-filter>
<!-- 系统启动完成后会调用-->
<action android:name="android.intent.action.BOOT_COMPLETED">
</action>
</intent-filter>
</receiver>