Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:06:44+00:00 2026-06-14T20:06:44+00:00

I am working on adding multiple alarm functionality in my existing app. Earlier, the

  • 0

I am working on adding multiple alarm functionality in my existing app. Earlier, the alarm was single only and every thing worked fine. I have been able to set multiple alarms, it is working fine too, but problem is with snooze feature. Earlier, snooze was working perfect. But, after multiple alarm implementation it is not working. I never get dialog for snoozing alarm, once I press snooze button. Here is my code:

Set alarm method

public void setAlarm(boolean AlarmEnabled, int AlarmHour, int AlarmMin) {
        //Build Intent/Pending Intent for setting the alarm
        Intent AlarmIntent = new Intent(MultipleAlarmActivity.this, AlarmReceiver.class);
        AlarmManager AlmMgr = (AlarmManager)getSystemService(ALARM_SERVICE);
        int _id = (int)System.currentTimeMillis();
        AlarmIntent.putExtra("REQUEST CODE", _id);
        Log.v("MultipleAlarmActivity RequestCode", ""+_id);
        PendingIntent Sender = PendingIntent.getBroadcast(MultipleAlarmActivity.this, _id, AlarmIntent, 0);     

        //Build Calendar objects for setting alarm
        Calendar curCalendar = Calendar.getInstance();
        Calendar alarmCalendar = Calendar.getInstance();

        //Initialize Seconds and Milliseconds to 0 for both calendars
        curCalendar.set(Calendar.SECOND, 0);
        curCalendar.set(Calendar.MILLISECOND, 0);           
        alarmCalendar.set(Calendar.SECOND, 0);
        alarmCalendar.set(Calendar.MILLISECOND, 0);

        //Update alarmCalendar with Alarm Hour and Minute Settings
        alarmCalendar.set(Calendar.HOUR_OF_DAY, AlarmHour);
        alarmCalendar.set(Calendar.MINUTE, AlarmMin);

        //If Alarm Time is now or in the past, set it for tomorrow 24 hours in advance from time selected
        if (alarmCalendar.getTimeInMillis() <= curCalendar.getTimeInMillis()) {
            alarmCalendar.add(Calendar.HOUR, 24);
        }
        //Set the alarm
        AlmMgr.set(AlarmManager.RTC_WAKEUP, alarmCalendar.getTimeInMillis(), Sender);

        //Build the Strings for displaying the alarm time through Toast
        String CalendarHourStr;
        if (AlarmHour > 12) {
            CalendarHourStr = Integer.toString(AlarmHour - 12);
        } else {
            CalendarHourStr = Integer.toString(AlarmHour);
        }
        String CalendarMinStr = Integer.toString(AlarmMin);
        if (AlarmMin < 10) {
            CalendarMinStr = "0" + CalendarMinStr;
        }

        String strAmPM;
        if (AlarmHour < 12) {
            strAmPM = "AM";
        }
        else {
            strAmPM = "PM";
        }
        String alarmTime = Integer.toString(alarmCalendar.get(Calendar.MONTH) + 1) + "/" + Integer.toString(alarmCalendar.get(Calendar.DAY_OF_MONTH)) + "/" + Integer.toString(alarmCalendar.get(Calendar.YEAR)) + " " + CalendarHourStr + ":" + CalendarMinStr + " " + strAmPM;
        Toast.makeText(this, "Alarm Set For " + alarmTime, Toast.LENGTH_LONG).show();       
         Log.v("MultipleAlarmActivity setAlarm", "in if loop");
    Log.v("MultipleAlarmActivity setAlarm", "setAlarm called");
} 

Alarm Receiver

public class AlarmReceiver extends BroadcastReceiver
{
public static final String ALARM_ALERT_ACTION = "com.android.alarmclock.ALARM_ALERT";
public static final String ALARM_INTENT_EXTRA = "intent.extra.alarm";

@Override
public void onReceive(Context context, Intent intent) 
{ 
    Intent in = new Intent(Intent.ACTION_MAIN);
    in.setClass(context, SnoozeActivity.class);
    Log.v("AlarmReceiver RequestCode", ""+intent.getIntExtra("REQUEST CODE", 0));
    in.putExtra("REQUEST CODE", intent.getIntExtra("REQUEST CODE", 0));
    in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(in);
}
}

Method for snoozing alarm

private void snooze() 
{
        //Set Calendar Value for Snooze Alarm
        Calendar calendar = Calendar.getInstance();
        //int snoozeTime = mMinute + SNOOZE_MIN;
        calendar.add(Calendar.MINUTE, SNOOZE_MIN); //SNOOZE_MIN = 1;
        long snoozeTime = calendar.getTimeInMillis();
        //Build Intent and Pending Intent to Set Snooze Alarm               
        Intent AlarmIntent = new Intent(SnoozeActivity.this, AlarmReceiver.class);
        AlarmManager AlmMgr = (AlarmManager)getSystemService(ALARM_SERVICE);
        AlarmIntent.putExtra("REQUEST CODE", req_code);
        PendingIntent Sender = PendingIntent.getBroadcast(SnoozeActivity.this, req_code, AlarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);   
        AlmMgr.set(AlarmManager.RTC_WAKEUP, snoozeTime, Sender);
        timer.cancel();   
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:06:45+00:00Added an answer on June 14, 2026 at 8:06 pm

    I found out the problem. I was using a boolean value for checking whether alarm has been set or not. And, I forgot to set this value as true when I called setAlarm(). Thats my mistake.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one jquery ui datepicker working fine. I am now adding a second
I have in-app purchases working in my production app, and I'm adding a new
I am adding myCustomView in a linear layout multiple times, it is working fine
I'm working on a Rails app using CanCan for RBAC and I only have
I am working on adding In-App purchases to my app. I am able to
I have a video that is 60 seconds long. I am working on adding
I've been working on adding Core Data into my iPhone app, and I've been
I am working on a multi-purpose page and rather than adding multiple grids to
Working with Crystal Reports over a multiple database environment. In the past reports have
I have my html5 form working to upload multiple mp3 files with one submit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.