我正在创建一个Android应用程序,它以编程方式创建应用程序关闭时保留的警报。为了有报警坚持,我只好定义接收器在我的清单如下所示:具有清单声明的独特PendingIntent
<receiver
android:name="com.blah.blah.AlarmReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter android:priority="999" >
<action android:name="com.blah.blah.ALARM" />
</intent-filter>
</receiver>
这里是我当前如何创建PendingIntents ..
Intent intent = new Intent(ACTION_ALARM);
PendingIntent pIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
AlarmManager manager = (AlarmManager (this.getSystemService(Context.ALARM_SERVICE));
由于我使用的是常量ACTION_ALARM,所有警报连接到相同的PendingIntent,因此调用.cancel()将删除所有警报。但是,我想删除特定的警报实例。我知道创建一个独特的PendingIntent的唯一方法是指定一个独特的动作,这与在上面定义我的Receiver在Manifest中存在冲突。有没有其他方法可以为我的警报制作可区分的PendingIntents?我也尝试添加数据,但似乎没有触发清单中的Receiver。
或者,如果我以编程方式为每个闹钟启动一个接收器,有没有办法让这些应用程序关闭时持续存在?
谢谢。