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

The Archive Base Latest Questions

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

I register alarms which I schedule to execute at given time, and it can

  • 0

I register alarms which I schedule to execute at given time, and it can be many alarms depending on the size of the scheduled list. But I have two questions which remains unclear to me:

1) How can I query the OS for the Pending Intents I registers? I need this for testing. The psudo code for what I want would be something like this:

List<PendingIntent> intentsInOS = context.getAllPendingIntentsOfType(AppConstants.INTENT_ALARM_SCHEDULE));

2) See the pending intent I create, I provide an action and extra data (the schedule id).

private Intent getSchedeuleIntent(Integer id) {

    Intent intent = new Intent(AppConstants.INTENT_ALARM_SCHEDULE);
    intent.putExtra(AppConstants.INTENT_ALARM_SCHEDULE_EXTRA, id);

    return intent;
}

But we also say that the intent have FLAG_CANCEL_CURRENT. Will it cancel all pending intents with same action, or does it have to both same action AND extra data?

PendingIntent pendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, getSchedeuleIntent(schedule.id), PendingIntent.FLAG_CANCEL_CURRENT);

My code

@Override
public void run() {

    List<ScheduledLocation> schedules = dbManager.getScheduledLocations();
    if(schedules == null || schedules.isEmpty()){
        return;
    }

    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    //alarmManager.

    // we need to get the number of milliseconds from current time till next hour:minute the next day.
    for(ScheduledLocation schedule : schedules){

        long triggerAtMillis = DateUtils.millisecondsBetweenNowAndNext(now, schedule.hour, schedule.minute, schedule.day);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, getSchedeuleIntent(schedule.id), PendingIntent.FLAG_CANCEL_CURRENT);

        alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtMillis, MILLISECONDS_IN_WEEK, pendingIntent);
    }

    // List<PendingIntent> intentsInOS = context.getAllPendingIntentsOfType(AppConstants.INTENT_ALARM_SCHEDULE));

}


private Intent getSchedeuleIntent(Integer id) {

    Intent intent = new Intent(AppConstants.INTENT_ALARM_SCHEDULE);
    intent.putExtra(AppConstants.INTENT_ALARM_SCHEDULE_EXTRA, id);

    return intent;
}
  • 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-14T00:44:02+00:00Added an answer on June 14, 2026 at 12:44 am

    1 How can I query the OS for the Pending Intents I registers?

    I’m not sure you can, but you can check if a specific PendingIntent is registered or not like this :

    private boolean checkIfPendingIntentIsRegistered() {
        Intent intent = new Intent(context, RingReceiver.class);
        // Build the exact same pending intent you want to check.
        // Everything has to match except extras.
        return (PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_NO_CREATE) != null);
    }
    

    2 Will it cancel all pending intents with same action, or does it have to both same action AND extra data?

    It will cancel all the PendingIntent that are resolved to be equal.

    What exactly does equal means ?

    The java doc of android says:

    Determine if two intents are the same for the purposes of intent
    resolution (filtering). That is, if their action, data, type, class,
    and categories are the same. This does not compare any extra
    data included in the intents.

    You can read at the 7391 line here : https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/content/Intent.java

    To sum up, all PendingIntent that are build exactly the same except extras will be cancelled.

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

Sidebar

Related Questions

I have an app which allows users to schedule alarms to sound at certain
I have read most posts re this issue, but still can't get my implementation
I have a small application which can be used to set reminders for future
using register_shutdown_function I can register code to execute at the end of a PHP
I made register form where you have to put in all your personal info.
I have searched a lot of places but couldnt find a clean sequential explanation
I have a 3-tier .NET service app, which follows the standard approach: Frontend ->
Can I register a .Net COM class with the SingleUse -flag? The reason I
i want to register my app users through http. what i have now is:
I want to be able to register two alarms to the same BroadcastReceiver. However,

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.