0

我想使用 AlarmManager 来调用 BroadcastReciever:

Context ctx=getApplicationContext();
Intent StartIntent = new Intent(ctx, tartReceiver.class);

AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC, StartTime.toMillis(false), PendingIntent.getActivity(ctx, 6,
                        StartIntent, PendingIntent.FLAG_CANCEL_CURRENT ));

接收者在清单中声明如下:

<receiver android:process=":remote" android:name=".StartReceiver" android:exported="true"/>

但什么都没有发生。如果我使用 ctx.sendBroadcast(StartIntent),则调用意图,所以应该没问题,还是不行?我还检查了 StartTime,它应该没问题,我也尝试了 0(这应该会导致根据文档立即调用 Intent)。

我必须改变什么才能让它工作?

4

1 回答 1

0

乔纳森克,

PendingIntent.getBroadcast()不想PendingIntent.getActivity()

于 2011-03-11T14:14:51.170 回答