अभी तक और इस वेबसाइट के लिए धन्यवाद, मैं एक अलार्म स्थापित करने में सक्षम हूं जो स्थापित और सक्रिय होगा, भले ही मैं अपना फोन चालू कर दूं।मैं एंड्रॉइड में एकाधिक अलार्म कैसे सेट कर सकता हूं?
अब, मैं घटना एक के लिए एक चेतावनी दिखाने के लिए एक अलार्म की स्थापना की और मैं सेटअप करने के लिए आवेदन एक और अलार्म घटना बी के लिए एक और अनुस्मारक दिखाने की जरूरत है
मैं कुछ गलत कर किया जाना चाहिए, क्योंकि यह केवल घटना ए के लिए अनुस्मारक को आग लगती है। ऐसा लगता है कि एक बार स्थापित होने पर, कोई अन्य अलार्म एक जैसा समझा जाता है।
1) एक गतिविधि से मैं अलार्म सेट है कि कुछ समय और तिथि पर एक रिसीवर
Intent intent = new Intent(Activity_Reminder.this,
AlarmReceiver_SetOnService.class);
intent.putExtra("item_name", prescription
.getItemName());
intent
.putExtra(
"message",
Activity_Reminder.this
.getString(R.string.notif_text));
intent.putExtra("item_id", itemId);
intent.putExtra("activityToTrigg",
"com.companyName.appName.main.Activity_Reminder");
PendingIntent mAlarmSender;
mAlarmSender = PendingIntent.getBroadcast(
Activity_Reminder.this, 0, intent, 0);
long alarmTime = dateMgmt.getTimeForAlarm(pickedDate);
Calendar c = Calendar.getInstance();
c.setTimeInMillis(alarmTime);
// Schedule the alarm!
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, alarmTime + 15000,
mAlarmSender);
कॉल करेगा:
यहाँ :-(क्या मैं दो चरणों में कर रहा हूँ के विस्तार है 2) रिसीवर से मैं एक सेवा को कॉल
Bundle bundle = intent.getExtras();
String itemName = bundle.getString("item_name");
String reminderOrAlarmMessage = bundle.getString("message");
String activityToTrigg = bundle.getString("activityToTrigg");
int itemId = Integer.parseInt(bundle.getString("item_id"));
NotificationManager nm = (NotificationManager) context.getSystemService("notification");
CharSequence text = itemName + " "+reminderOrAlarmMessage;
Notification notification = new Notification(R.drawable.icon, text,
System.currentTimeMillis());
Intent newIntent = new Intent();
newIntent.setAction(activityToTrigg);
newIntent.putExtra("item_id", itemId);
CharSequence text1= itemName + " "+reminderOrAlarmMessage;
CharSequence text2= context.getString(R.string.notif_Go_To_Details);
PendingIntent pIntent = PendingIntent.getActivity(context,0, newIntent, 0);
notification.setLatestEventInfo(context, text1, text2, pIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_ALL;
nm.notify(itemId, notification);
अग्रिम धन्यवाद,
monn3t
आप चुरा लिया ... आप क्या सुझाव चाल किया धन्यवाद। क्योंकि मुझे यकीन है कि यह ठीक से काम कर रहा था बनाना चाहते थे कि मैंने पहले का जवाब नहीं दिया है और यह है ... फिर से धन्यवाद, monn3t – monn3t
@stOle: http: // stackoverflow कृपया मुझे भी इस एक के लिए मदद करते हैं। कॉम/प्रश्न/8665021/एंड्रॉइड-एकाधिक-अलार्म-काम नहीं कर रहे/8665978 # 8665978 –
@ st0le: मैं अलग-अलग तारीख और समय के लिए अलार्म प्राप्त करने में सक्षम हूं लेकिन वे सभी एक ही संदेश प्रसारित करते हैं। इसे कैसे संभालें?मैं अलग-अलग अलार्म के लिए अलग संदेश सेट करना चाहता हूं। । । –