2016-03-20 10 views
-2

他の人が(異なるタイミングで)複数の通知をスケジュールするために、以下のコードにどのような変更を加えなければならないか教えてください。アクティビティから複数の通知をスケジュールするにはどうすればよいですか?

Intent notificationIntent = new Intent(this, NotificationPublisher.class); 
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); 
    AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE); 
    alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent); 

これは私がBroadcastReceiverを拡張するクラスを追加して、私のAndroidのマニフェストファイルの一部です:現時点では

 </activity> 
    <receiver android:name=".NotificationPublisher"/> 
</application> 

だけ私の最後のスケジュールの通知が表示されます。

答えて

0

私の愚かな質問には申し訳ありません。私は、PendingIntent.getBroadcast()のパラメータが何であるかについてはっきりしていませんでした。 私がしなければならなかったのは、2番目のパラメータを変更して一意のPendingIntentsを作成することでした。

関連する問題