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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:08:51+00:00 2026-06-09T11:08:51+00:00

How can I cancel one AlarmManager on a scheduled time, which was already started.

  • 0

How can I cancel one AlarmManager on a scheduled time, which was already started. I am starting one AlarmManager like this.

I want to cancel it after 5 hours. How can I do this?

AlarmManager service = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(context, MyStartServiceReceiver.class);
PendingIntent pending = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, 30);
service.setInexactRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), REPEAT_TIME, pending);
  • 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-09T11:08:53+00:00Added an answer on June 9, 2026 at 11:08 am

    set a another alarm for 5 hours from now. when this alarm alarm goes off then cancel the first alarm.

    AlarmManager service = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent intentForCancelling = new Intent(context, ReceiverForCancelling.class);
    PendingIntent pending = PendingIntent.getBroadcast(context, 0, intentForCancelling,
    PendingIntent.FLAG_CANCEL_CURRENT);
    Calendar cal = Calendar.getInstance();
    cal.roll(Calendar.HOUR_OF_DAY, 5);
    service.set(AlarmManager.RTC_WAKEUP,
    cal.getTimeInMillis(), pending)
    

    and, from ReceiverForCancelling you can cancel the first alarm.
    edit::

    AlarmManager service = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(context, ReceiverForCancelling.class);
    PendingIntent pending = PendingIntent.getBroadcast(context, 0, intent,
    PendingIntent.FLAG_CANCEL_CURRENT);
    service.cancel(pending);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can't believe I am losing so much time on this one. I have an
I have a cancel button on a page. But this page can be opened
I have a before_save observer in one of my models, can I cancel the
can any one tell me the way to design vista like buttons using CSS
i have one submit form. i want if someone submit same data can show
I'm trying to figure out how I can listen to the Cancel button that
Can any one tell, how to get the result of LINQ query contains group
How do I achieve this:- When user types character like 'abcd' and then '>'
I have a form with two submit buttons - one for Cancel and the
Can you cast an object to one that implements an interface? Right now, I'm

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.