我知道当您onReceive()
在BroadcastReceiver
.
但是,这是 my 的代码onReceive()
,建议:
@Override
public void onReceive(Context context, Intent intent) {
// TODO Iniciando classes
Intent iLocator = new Intent(context, LocatorService.class);
context.startService(iLocator);
}
Intent 是通过这个方法发送的:
public void agendarPing() {
Intent it = new Intent("EXECUTA");
PendingIntent p = PendingIntent.getBroadcast(LocatorService.this, 0,
it, 0);
Calendar c = Calendar.getInstance();
c.setTimeInMillis(System.currentTimeMillis());
c.add(Calendar.SECOND, 360);
long tempoReabrir = c.getTimeInMillis();
AlarmManager reabrir = (AlarmManager) getSystemService(ALARM_SERVICE);
reabrir.set(AlarmManager.RTC_WAKEUP, tempoReabrir, p);
Log.d(TAG, "Alarme agendado com sucesso!");
stopSelf();
}
为什么我要有这个日志?
04-24 08:41:40.742: W/ActivityManager(1483): Timeout of broadcast BroadcastRecord{40b3f1c0 EXECUTA} - receiver=android.os.BinderProxy@40bcfef0, started 20008ms ago
04-24 08:41:40.742: W/ActivityManager(1483): Receiver during timeout: ResolveInfo{40b78208 br.com.contele.locator.LocatorReceiver p=0 o=0 m=0x108000}