package com.uiui.sn.receiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; import com.baidu.location.BDAbstractLocationListener; import com.baidu.location.BDLocation; import com.baidu.location.LocationClient; import com.uiui.sn.manager.AmapManager; import com.uiui.sn.network.NetInterfaceManager; import com.uiui.sn.service.ControlPanelService; import com.uiui.sn.service.GuardService; import com.uiui.sn.service.main.MainService; import com.uiui.sn.service.ManagerService; import com.uiui.sn.service.DownloadService; import com.uiui.sn.service.StepService; public class BootReceiver extends BroadcastReceiver { private static String TAG = BootReceiver.class.getSimpleName(); public static final String BOOT_COMPLETED = "zuoyeos.action.BOOT_COMPLETED"; public static final String SOS = "zuoyeos.action.SOS"; @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Log.e("SNBootReceiver", action); if (Intent.ACTION_BOOT_COMPLETED.equals(action) || Intent.ACTION_BATTERY_CHANGED.equals(action) || Intent.ACTION_BATTERY_LOW.equals(action) || Intent.ACTION_BATTERY_OKAY.equals(action) || Intent.ACTION_POWER_CONNECTED.equals(action) || Intent.ACTION_POWER_DISCONNECTED.equals(action) || Intent.ACTION_DATE_CHANGED.equals(action) || Intent.ACTION_TIME_TICK.equals(action) || Intent.ACTION_USER_PRESENT.equals(action) || Intent.ACTION_SCREEN_ON.equals(action) || Intent.ACTION_SCREEN_OFF.equals(action) || BOOT_COMPLETED.equals(action) || "android.intent.action.BATTERY_LEVEL_CHANGED".equals(action) ) { context.startService(new Intent(context, MainService.class)); context.startService(new Intent(context, GuardService.class)); context.startService(new Intent(context, StepService.class)); context.startService(new Intent(context, DownloadService.class)); context.startService(new Intent(context, ManagerService.class)); context.startService(new Intent(context, ControlPanelService.class)); } else if (SOS.equals(action)) { LocationClient locationClient = AmapManager.getInstance().getLocationClient(); locationClient.stop(); locationClient.start(); locationClient.registerLocationListener(new BDAbstractLocationListener() { @Override public void onReceiveLocation(BDLocation bdLocation) { Log.e(TAG, "onReceiveLocation: "); NetInterfaceManager.getInstance().updateAdminInfo(); } }); } } }