Android 安卓提醒打盹问题

Android 安卓提醒打盹问题,android,reminders,snoop,Android,Reminders,Snoop,我已经创建了一个带有打盹选项的提醒应用程序。。当只为一个提醒激活打盹时,一切正常。。当我添加第二个提醒时,第一个提醒被第二个提醒复制(覆盖)。。我在这里输入了密码。请帮帮我。。 memberActivity.java reminButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { contentTitle =

我已经创建了一个带有打盹选项的提醒应用程序。。当只为一个提醒激活打盹时,一切正常。。当我添加第二个提醒时,第一个提醒被第二个提醒复制(覆盖)。。我在这里输入了密码。请帮帮我。。

memberActivity.java

reminButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            contentTitle = nameEdit.getText().toString();
            contentText = descEdit.getText().toString();
            contentSnooze = snoozeEdit.getText().toString();


                time = mYear + "-" + mMonth + "-" + mDay + " " + mHour
                        + "-" + mMinute;
                SimpleDateFormat df = new SimpleDateFormat(
                        "yyyy-MM-dd hh-mm");
                Date dt = null;
                try {
                    dt = df.parse(time);
                } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (java.text.ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                long when = dt.getTime();

                AlarmManager mgr = (AlarmManager) mContext
                        .getSystemService(Context.ALARM_SERVICE);
                Intent notificationIntent = new Intent(mContext,
                        ReminderAlarm.class);
                notificationIntent.putExtra("Name", contentTitle);
                notificationIntent.putExtra("Description", contentText);
                notificationIntent.putExtra("NotifyCount",
                        notificationCount);
                PendingIntent pi = PendingIntent.getBroadcast(mContext,
                        notificationCount, notificationIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                mgr.set(AlarmManager.RTC_WAKEUP, when, pi);
                Toast.makeText(mContext, contentTitle +" Reminder Activated" + notificationCount,
                        Toast.LENGTH_LONG).show();




        }
arm.java

public void onReceive(Context context, Intent intent) {

    mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    CharSequence name = intent.getStringExtra("Name");
    CharSequence desc = intent.getStringExtra("Description");
    notificationCount = Integer.parseInt(intent.getExtras().get("NotifyCount")
            .toString());

    sound = new Sound(context);
    sound.play();

    Intent notifyIntent = new Intent(context, ReminderPopup.class);
    notifyIntent.putExtra("Name", name);
    notifyIntent.putExtra("Description", desc);
    notifyIntent.putExtra("NotifyCount", notificationCount);
    PendingIntent contentIntent = PendingIntent.getActivity(context, notificationCount,
            notifyIntent, 0);

    notification = new Notification(R.drawable.ic_launcher, "Notification",
            System.currentTimeMillis());
    notification.setLatestEventInfo(context, name, desc, contentIntent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    mNotificationManager.notify(
            Integer.parseInt(intent.getExtras().get("NotifyCount")
                    .toString()), notification);
java

public void onClick(DialogInterface dialog, int which) {
            if (minute != 0) {



                cal = Calendar.getInstance();
                mYear = cal.get(Calendar.YEAR);
                mMonth = cal.get(Calendar.MONTH) + 1;
                mDay = cal.get(Calendar.DATE);
                mHour = cal.get(Calendar.HOUR_OF_DAY);
                mMinute = cal.get(Calendar.MINUTE);
                snooze = mYear + "-" + mMonth + "-" + mDay + " " + mHour
                        + "-" + (mMinute + minute);
                SimpleDateFormat df = new SimpleDateFormat(
                        "yyyy-MM-dd hh-mm");
                Date dt = null;
                try {
                    dt = df.parse(snooze);
                } catch (ParseException e) {
                    e.printStackTrace();
                } catch (java.text.ParseException e) {
                    e.printStackTrace();
                }
                when = dt.getTime();

                AlarmManager mgr = (AlarmManager) getApplicationContext()
                        .getSystemService(Context.ALARM_SERVICE);
                Intent notificationIntent = new Intent(
                        getApplicationContext(), ReminderAlarm.class);
                notificationIntent.putExtra("Name", name);

                notificationIntent.putExtra("Description", desc);

                notificationIntent.putExtra("NotifyCount",
                        notificationCount);
                PendingIntent pi = PendingIntent.getBroadcast(
                        getApplicationContext(), notificationCount,
                        notificationIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                mgr.set(AlarmManager.RTC_WAKEUP, when, pi);
                Toast.makeText(getApplicationContext(),
                        name +" Reminder Snoozed for " + minute + " Minutes " + notificationCount,
                        Toast.LENGTH_LONG).show();
            }

我找到了这个问题的答案。。我使用“android:theme=“@style/theme\u Dialog\u transparent”>”将提醒器opup活动设置为透明活动。当我设置打盹时,只有AlertDialog将消失,而不是MemberPoup(透明)活动。因此,当我设置下一次打盹时,它将更新现有的打盹。将finish()添加到AlertDialog的末尾,用于正负按钮。

PendingEvent.FLAG\u UPDATE\u CURRENT);这导致了这个问题。它将用现有的更新新的待定,谢谢你,泰米尔塞尔万先生。这就是我最初的想法。但后来我找到了。我把答案贴在这里。
public void onClick(DialogInterface dialog, int which) {
            if (minute != 0) {



                cal = Calendar.getInstance();
                mYear = cal.get(Calendar.YEAR);
                mMonth = cal.get(Calendar.MONTH) + 1;
                mDay = cal.get(Calendar.DATE);
                mHour = cal.get(Calendar.HOUR_OF_DAY);
                mMinute = cal.get(Calendar.MINUTE);
                snooze = mYear + "-" + mMonth + "-" + mDay + " " + mHour
                        + "-" + (mMinute + minute);
                SimpleDateFormat df = new SimpleDateFormat(
                        "yyyy-MM-dd hh-mm");
                Date dt = null;
                try {
                    dt = df.parse(snooze);
                } catch (ParseException e) {
                    e.printStackTrace();
                } catch (java.text.ParseException e) {
                    e.printStackTrace();
                }
                when = dt.getTime();

                AlarmManager mgr = (AlarmManager) getApplicationContext()
                        .getSystemService(Context.ALARM_SERVICE);
                Intent notificationIntent = new Intent(
                        getApplicationContext(), ReminderAlarm.class);
                notificationIntent.putExtra("Name", name);

                notificationIntent.putExtra("Description", desc);

                notificationIntent.putExtra("NotifyCount",
                        notificationCount);
                PendingIntent pi = PendingIntent.getBroadcast(
                        getApplicationContext(), notificationCount,
                        notificationIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                mgr.set(AlarmManager.RTC_WAKEUP, when, pi);
                Toast.makeText(getApplicationContext(),
                        name +" Reminder Snoozed for " + minute + " Minutes " + notificationCount,
                        Toast.LENGTH_LONG).show();
            }