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

  • Home
  • SEARCH
  • 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 8757123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:13:46+00:00 2026-06-13T14:13:46+00:00

I want to use alarms to trigger some processing. In the code below, I

  • 0

I want to use alarms to trigger some processing.

In the code below, I have tried to set two alarms. They trigger a Service which displays a Notification indicating the id number of the alarm which has just gone off.

When the first Alarm goes off, a Notification should appear and display : “1”.
For the second Alarm, the Notification should show “2”.

As described in the Javadoc, only one alarm is triggered (they have the same Intent, so the second one replaces the first one). But what is strange is that the Notification displays “1” and appears at the time when the second Alarm goes off!!! It seems that the time for the alarm to go off is modified but not the extras.

Any idea?

Thanks in advance for the time you will spend trying to help me.

public class TestAlarmes extends Activity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState){
    AlarmManager am;
    Intent action;
    PendingIntent intent;
    long t0;
    RecepteurMessageAlarme récepteur;

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // créer le récepteur de message d'alarme
    récepteur=new RecepteurMessageAlarme();

    // et l'enregistrer en lui demandant de filtrer sur les messages d'alarme
    registerReceiver(récepteur,new IntentFilter("GL.TestAlarmes.ALARME"));

    // récupérer le service d'alarme
    am=(AlarmManager)getSystemService(Context.ALARM_SERVICE);

    // créer l'action 1
    action=new Intent(this,ServiceAlarme.class);
    action.setAction("GL.TestAlarmes.ALARME");

    // personnaliser l'action a exécuter
    action.putExtra("GL.TestAlarmes.Action",1);

    // créer l'intent à lancer lors du déclenchement de l'alarme
    intent=PendingIntent.getService(this,0,action,PendingIntent.FLAG_ONE_SHOT);

    // prendre l'instant présent
    t0=java.lang.System.currentTimeMillis();

    // configurer l'alarme
    am.set(AlarmManager.RTC_WAKEUP,t0+5000,intent);

    // créer l'action 2
    action=new Intent(this,ServiceAlarme.class);
    action.setAction("GL.TestAlarmes.ALARME");

    // personnaliser l'action a exécuter
    action.putExtra("GL.TestAlarmes.Action",2);

    // créer l'intent à lancer lors du déclenchement de l'alarme
    intent=PendingIntent.getService(this,0,action,PendingIntent.FLAG_ONE_SHOT);

    // configurer l'alarme
    am.set(AlarmManager.RTC_WAKEUP,t0+10000,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-13T14:13:47+00:00Added an answer on June 13, 2026 at 2:13 pm

    Try giving different request codes for PendingIntent to make it unique

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

Sidebar

Related Questions

i want use some data from a website with web service. i have a
I want to set alrms so i use this code. UILocalNotification *localNotif = [[UILocalNotification
I want to use an alarm to run some code at a certain time.
I want to code an app that displays some information in an widget, which
I have the following code to trigger an alarm, which when it fires is
I want use this 1 for using Bar code or QR code scanner. I
I don't want use old Visual Basic methods in my code, and I'm confused
We have a powerbuilder application and we want use a scanner through this application
I am implementing some code and I want to run it in regular time(auto
I have an update service that starts at boot. The thing is I want

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.