public class MyBroadcastReceive extends BroadcastReceiver {
static final String action_boot="android.intent.action.BOOT_COMPLETED";
@Override
public void onReceive(Context ctx, Intent intent) {
Log.d("BootReceiver", "system boot completed");
if (intent.getAction().equals(action_boot)){
//start service
try {
Intent s=new Intent(ctx,WatchDogService.class);
ctx.startService(s);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
AndroidManifest.xml里权限也加了 可是一开机就显示”很抱歉 程序***已停止运行“ 但是正常运行程序不会报错