1、开机启动服务
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class BootCompleteReceiver extends BroadcastReceiver {
private static final String TAG = "BootCompleteReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Intent service = new Intent(context, PushService.class);
context.startService(service);
Log.i(TAG, "Boot Complete. Starting PushService...");
}
}
在xml文件中的注释说明为:
<!-- 开机广播接受者 -->
<receiver android:name=".BootCompleteReceiver">
<intent-filter>
<!-- 注册开机广播地址-->
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name&