क्या एंड्रॉइड में यह पता लगाने के लिए कोई तरीका है कि उपयोगकर्ता बाईं ओर अधिसूचना को स्वाइप करता है और इसे हटा देता है? मैं एक दोहराने वाली चेतावनी सेट करने के लिए अलार्ममैनगर का उपयोग कर रहा हूं और जब उपयोगकर्ता द्वारा अधिसूचना रद्द की जाती है तो मुझे रोकने के लिए मेरी दोहराने वाली चेतावनी की आवश्यकता होती है।यह पता लगाने के लिए कि क्या कोई अधिसूचना खारिज कर दी गई है?
दोहराई जाने वाली चेतावनी की स्थापना:
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), repeatFrequency, displayIntent);
मेरी सूचना कोड:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Get the notification ID.
int notifID = getIntent().getExtras().getInt("Reminder_Primary_Key");
//Get the name of the reminder.
String reminderName = getIntent().getExtras().getString("Reminder_Name");
//PendingIntent stores the Activity that should be launched when the user taps the notification.
Intent i = new Intent(this, ViewLocalRemindersDetail.class);
i.putExtra("NotifID", notifID);
i.putExtra("notification_tap", true);
//Add FLAG_ACTIVITY_NEW_TASK to stop the intent from being launched when the notification is triggered.
PendingIntent displayIntent = PendingIntent.getActivity(this, notifID, i, Intent.FLAG_ACTIVITY_NEW_TASK);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notif = new Notification(R.drawable.flag_red_large, reminderName, System.currentTimeMillis());
CharSequence from = "Here's your reminder:";
CharSequence message = reminderName;
notif.setLatestEventInfo(this, from, message, displayIntent);
//Pause for 100ms, vibrate for 250ms, pause for 100ms, and vibrate for 500ms.
notif.defaults |= Notification.DEFAULT_SOUND;
notif.vibrate = new long[] { 100, 250, 100, 500 };
nm.notify(notifID, notif);
//Destroy the activity/notification.
finish();
}
मैं जानता हूँ कि मैं आदेश मेरी दोहरा अलार्म को रद्द करने में alarmManager.cancel(displayIntent)
कॉल करने की आवश्यकता यहाँ मेरी कोड है। हालांकि, मुझे नहीं पता कि यह कोड कहां रखना है। मुझे केवल दोहराना चेतावनी रद्द करने की आवश्यकता है जब उपयोगकर्ता ने अधिसूचना पर टैप किया है या इसे खारिज कर दिया है। आपकी सहायताके लिए धन्यवाद!
कोई बात नहीं, मुझे मेरा जवाब यहां मिला: http://stackoverflow.com/questions/8811876/notification-deleteintent-does-not-work। – NewGradDev