Stack Exchange
Alarm Broadcasting class is not repeating the alarm again
Please guide me so that the alarm (mail sending) will compile again and provide me mail before 1 day of event occurring and then before 30 minutes of event occurring.
Thanks in Advance.
public class MailAlarm extends BroadcastReceiver{

    NotificationManager nm;

    public void onReceive(Context context, Intent intent) {

        nm = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);

        //int iUniqueId = (int) (System.currentTimeMillis() & 0xfffffff);

        String event = Mail_Fill_Details.Discripton;
        String name = Mail_Fill_Details.Person_Name;
        String mail =Mail_Fill_Details.mailString;
        try {   
            GMailSender sender = new GMailSender("taskschedulerfable@gmail.com", "xyz");
            sender.sendMail("Reminder of "+event+" ("+name+")" ,   
                    "REMINDER!! REMINDER!! REMINDER!! \n\n\nYou got a reminder about "+event+"("+name+") after 5 minutes\n\n\n",   
                    "taskschedulerfable@gmail.com",   
                    mail);   
        } catch (Exception e) {   
            Log.e("SendMail", e.getMessage(), e);   
        }

Rest code is here...
Intent intent = new Intent(Mail_Fill_Details.this,
                                MailAlarm.class);
                        Bundle b12 = new Bundle();

                        b12.putString("serverresponse", Discripton);
                        b12.putString("serverresponse1", Person_Name);
                        b12.putString("serverresponce2", mailString);

                        intent.setAction("" + Math.random());
                        intent.putExtras(b12);
                        PendingIntent displayIntent = PendingIntent
                                .getBroadcast(Mail_Fill_Details.this,
                                        iUniqueId, intent,
                                        PendingIntent.FLAG_UPDATE_CURRENT);
                        alarmManager.set(AlarmManager.RTC_WAKEUP,
                                calendar.getTimeInMillis() - 300000,
                                displayIntent);
                        // alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
                        // calendar.getTimeInMillis(), 20, displayIntent);


you need to include the part where you are sending the broadcast, because 'MailAlarm not being invoked' seems like that could be the problem

@Zakaria please tell me how to include code so that it will not be edited.

@waqas it is sending but it is not sending again...

that's what I'm asking, post that code too, so we can see why isn't it sending again.

I think you should use setRepeating method of AlarmManager instead set method.
am.setRepeating(type, triggerAtMillis, intervalMillis, operation);


yes you are right sir but it will continue repeating again and again. I need to repeat only one time.

@VarunVishnoi then use 'set' method only.. have one SharedPreference for ex: "broadcasted","yes" ... in broadcast receiver check if its "no" then set again ..else don't set..this way it will be set and broadcast only two time
----------------- OR -----------------------
you can also check the same way and when its "true" cancel the alarm.

To contact come here I am Online in day time  @VarunVishnoi

I am unable to use chat because of less reputation as i m new to stackoverflow any other medium sir? @MkJParekh

@VarunVishnoi I think, you got 20 and its enough. please I am not "sir" and not that old :D

hehehe thanks alot. The resectful word sir doesnt tell about age here. Its just because of your excellence in coding and all.. So once again thank you sir.
