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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:08:09+00:00 2026-06-17T01:08:09+00:00

i have set some alarm like: public void SetAlarm(Context context, int tag, long time){

  • 0

i have set some alarm like:

public void SetAlarm(Context context, int tag, long time){
     AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
     Intent i = new Intent(context, Alarm.class);
     i.putExtra("position", tag);
     PendingIntent pi = PendingIntent.getBroadcast(context, tag, i, PendingIntent.FLAG_CANCEL_CURRENT);
     am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+ time, pi); // Millisec * Second * Minute

 }

now for some reason i want to update the Intent i of a triggered alarm. i have the id(tag) for identify the desire alarm. how can i do that ?

  • 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-17T01:08:10+00:00Added an answer on June 17, 2026 at 1:08 am

    If all you want to do is change the extras in the Intent, you can do it like this:

    Intent i = new Intent(context, Alarm.class);
    // Set new extras here
    i.putExtra("position", tag);
    // Update the PendingIntent with the new extras
    PendingIntent pi = PendingIntent.getBroadcast(context, tag, i,
            PendingIntent.FLAG_UPDATE_CURRENT);
    

    Otherwise, if you want to change anything else in the Intent (like the action, or component, or data), you should cancel the current alarm and create a new one like this:

    AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
    Intent i = new Intent(context, Alarm.class);
    // Extras aren't used to find the PendingIntent
    PendingIntent pi = PendingIntent.getBroadcast(context, tag, i,
            PendingIntent.FLAG_NO_CREATE); // find the old PendingIntent
    if (pi != null) {
        // Now cancel the alarm that matches the old PendingIntent
        am.cancel(pi);
    }
    // Now create and schedule a new Alarm
    i = new Intent(context, NewAlarm.class); // New component for alarm
    i.putExtra("position", tag); // Whatever new extras
    pi = PendingIntent.getBroadcast(context, tag, i, PendingIntent.FLAG_CANCEL_CURRENT);
    // Reschedule the alarm
    am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+ time, pi); // Millisec * Second * Minute
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my init I have set some variables and one animate that uses those
I have one AlertDialog which is working fine.I have set some background images to
I have to set some routing rules in my php application, and they should
I have some set of xml generated via xmlserialization of some WCF messages. Now
I have set inside .bashrc some aliases that I need to be seen inside
I want to set some locations and have my app check if its by
I have java script code to set some of the properties of ajax controls.
I have a floated span with some text. I have set the overflow to
I'm using Google Test Framework to set some unit tests. I have got three
I am doing some research into geolocation in web pages. I have set up

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.