0
我在分析中存儲日期和時間,並得到所有數據,但即使是單個鬧鐘也沒有被觸發。例如,我將時間存儲在數據庫中,例如下午2點,下午3點,下午4點等,以及它們的日期,但不會觸發警報。 請幫助我..多個鬧鐘沒有設置
這是我的主類
ArrayList<PendingIntent> intentArray;
AlarmManager alarmManager =(AlarmManager)getSystemService(ALARM_SERVICE);
intentArray = new ArrayList<PendingIntent>();
Calendar calendar=Calendar.getInstance();
ParseQuery<ParseObject> query = ParseQuery.getQuery("Description");
query.whereEqualTo("user", user);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e)
if (e == null) {
int count = 0;
for (ParseObject obj : list) {
calendar.set(Calendar.YEAR, obj.getInt("Year"));
calendar.set(Calendar.MONTH, obj.getInt("Month"));
calendar.set(Calendar.DAY_OF_MONTH, obj.getInt("Day"));
calendar.set(Calendar.HOUR_OF_DAY, obj.getInt("Hour"));
calendar.set(Calendar.MINUTE, obj.getInt("Miniute"));
calendar.set(Calendar.SECOND, 0);
Intent intent = new Intent("net.learn2develop.DisplayNotification");
intent.putExtra("NotifID", 1);
PendingIntent
pendingIntent=PendingIntent.getActivity(getBaseContext(),ncount++,intent,
0);
alarmManager.set(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis()
,pendingIntent);
intentArray.add(pendingIntent);
}//end for loop
} else {
Log.d("Test", "Error Occur");
}
});
}
但我做了同樣的什麼是錯在我的代碼? –
您需要使用PendingIntent.getBroadcast,它將爲待定意圖採用不同的廣播ID。 PendingIntent pendingIntent = PendingIntent.getBroadcast(context,i,intent,0); – Naresh