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 6706213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:29:39+00:00 2026-05-26T07:29:39+00:00

I am facing problem with canceling the particular alarm. I am setting multiple alarm

  • 0

I am facing problem with canceling the particular alarm. I am setting multiple alarm using alarm manager SET method. But i am not able to cancel the particular alarm. If i cancel, it is canceling all the alarm previously set. I am using single ALARM MANAGER ID to set the multiple alarms.

SAVE METHOD

private void saveState() 
{
    //  String date = mDateText.getText().toString();
    String title = mTitleText.getText().toString(); 
    String body = mBodyText.getText().toString();
    String sdate = sDateText.getText().toString();
    String stime = sTimeText.getText().toString();   
    String rdate = rDateText.getText().toString();   
    String rtime = rTimeText.getText().toString();   

    String appRemDate = ((Button)findViewById(R.id.enterdaterem)).getText().toString();
    String appRemTime = ((Button)findViewById(R.id.entertimerem)).getText().toString();


    Calendar cal = Calendar.getInstance(); 

    //setting date & month
    if(appRemDate.substring(0,2).endsWith("-" ) && appRemDate.substring(2,4).endsWith("-" ))
    { 

        cal.set(Calendar.YEAR, Integer.parseInt(appRemDate.substring(4,8)));
        cal.set(Calendar.MONTH, Integer.parseInt(appRemDate.substring(2,3)) -1);
        cal.set(Calendar.DATE, Integer.parseInt(appRemDate.substring(0,1))); 
    }
    else if( !appRemDate.substring(0,2).contains("-" ) && !appRemDate.substring(3,5).contains("-" ) )
    {  

        cal.set(Calendar.YEAR, Integer.parseInt(appRemDate.substring(6,10)));
        cal.set(Calendar.MONTH, Integer.parseInt(appRemDate.substring(3,5)) -1);
        cal.set(Calendar.DATE, Integer.parseInt(appRemDate.substring(0,2))); 
    }
    else if( appRemDate.substring(0,2).endsWith("-" ) && !appRemDate.substring(2,4).endsWith("-" ))
    {  
        cal.set(Calendar.YEAR, Integer.parseInt(appRemDate.substring(5,9)));
        cal.set(Calendar.MONTH, Integer.parseInt(appRemDate.substring(2,4)) -1);
        cal.set(Calendar.DATE, Integer.parseInt(appRemDate.substring(0,1))); 
    }
    else  
    {  
        cal.set(Calendar.YEAR, Integer.parseInt(appRemDate.substring(5,9)));
        cal.set(Calendar.MONTH, Integer.parseInt(appRemDate.substring(3,4)) -1);
        cal.set(Calendar.DATE, Integer.parseInt(appRemDate.substring(0,2))); 
    } 
    cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(appRemTime.substring(0, 2))); 

    cal.set(Calendar.MINUTE, Integer.parseInt(appRemTime.substring(3, 5)));

    cal.set(Calendar.SECOND, 0); 

    if (mRowId == null) 
    {
        long id = mDbHelper.createNote(  title, body, sdate, stime, rdate, rtime);
        invokeAlaram( cal.getTimeInMillis(), id );
        if (id > 0) 
        {
            mRowId = id;
        }
    } 
    else 
    { 
        long id = mDbHelper.updateNote(mRowId,  title, body, sdate, stime, rdate, rtime);
        invokeAlaram( cal.getTimeInMillis(),   id );
    }
}

INVOKE ALARM METHOD

private void invokeAlaram(long invokeTime, long id )
{

    AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE); 

    Intent i =  new Intent(this, MyAlarmServiceForAppointments.class);

    i.putExtra("rowId", String.valueOf(id));
    am.set(AlarmManager.RTC_WAKEUP, invokeTime,   PendingIntent.getService(this , (int) System.currentTimeMillis() ,i , 0));

} 

Can anyone help me how to cancel the particular alarm.

  • 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-05-26T07:29:39+00:00Added an answer on May 26, 2026 at 7:29 am

    as you pass the system millisecond time for the request code into the getService() like here

    am.set(AlarmManager.RTC_WAKEUP, invokeTime,   PendingIntent.getService(this , (int) System.currentTimeMillis() ,i , 0));
    

    instead of using system time you have to pass your unique number which consider as request was different for specific intent.

    Now you have to keep this all request code based on this you can cancel the alarm

    Note: As the Intent object you pass into the PendingIntent that must be same define for cancelling the alarm as you defined at set time

    am.set(AlarmManager.RTC_WAKEUP, invokeTime,   PendingIntent.getService(this , 1 ,i , 0));
    
    am.set(AlarmManager.RTC_WAKEUP, invokeTime,   PendingIntent.getService(this , 2 ,i , 0));
    

    and so on

    now for cancel

    am.cancel(PendingIntent.getService(this , 2 ,i , 0));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm facing this problem again and again, but can't find any solution (except mine,
I'm facing a problem that seems to have no straighforward solution. I'm using java.util.Map
I am facing problem in getting Facebook data I am using Facebook SDK for
I am facing problem when url is redirected. I set webviewclient and It is
I am facing problem to set a perticulat value of a custom JComboBox. If
I am trying to hide an array of elements but facing problem while writing
I am using Eclipse Helios. Last days I am facing problem that Eclipse Helios
i am facing problem with the return type for this function and not really
I'm facing problem in setting my record value. I have nested record inside store
Hi i have done with status update in tumbler but i am facing problem

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.