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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:24:44+00:00 2026-06-15T02:24:44+00:00

Im trying to set an alarm that will send an intent to a broadcast

  • 0

Im trying to set an alarm that will send an intent to a broadcast receiver. The reciever should then print a line in the logcat stating it has worked. However I’m getting no indication that the reciever is receiving anything. I’ve checked all the things I can think of. Can someone give me some guidance as I am at a loss?

Alarm Method

public void scheduleNextUpdate()
      {

        Intent intent = new Intent(MainActivity.this,AlarmReceiver.class);
        PendingIntent pendingIntent =
            PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);


        long currentTimeMillis = System.currentTimeMillis();
        long nextUpdateTimeMillis = currentTimeMillis * DateUtils.MINUTE_IN_MILLIS;
        Time nextUpdateTime = new Time();
        nextUpdateTime.set(nextUpdateTimeMillis);

        if (nextUpdateTime.hour < 8 || nextUpdateTime.hour >= 22)
        {
          nextUpdateTime.hour = 8;
          nextUpdateTime.minute = 0;
          nextUpdateTime.second = 0;
          nextUpdateTimeMillis = nextUpdateTime.toMillis(false) + DateUtils.DAY_IN_MILLIS;
        }
        AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
        alarmManager.set(AlarmManager.RTC, nextUpdateTimeMillis, pendingIntent);
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, nextUpdateTimeMillis,nextUpdateTimeMillis,pendingIntent);

        boolean alarmUp = (PendingIntent.getBroadcast(this, 0, 
                new Intent(MainActivity.this,AlarmReceiver.class), 
                PendingIntent.FLAG_NO_CREATE) != null);

        if (alarmUp)
        {
            Log.d("myTag", "Alarm is already active");
        }
}

ReceiverClass

public class AlarmReceiver extends BroadcastReceiver {
    @Override
     public void onReceive(Context context, Intent intent) {  
         System.out.println("Alarm Received");
    intent = new Intent(context, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);
     System.out.println("Alarm Received");
}

The manifest

<receiver android:name=".AlarmReceiver"></receiver>
  • 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-15T02:24:45+00:00Added an answer on June 15, 2026 at 2:24 am

    This math seems wrong. I believe you are trying to set an alarm that won’t go off for a few generations:

    long currentTimeMillis = System.currentTimeMillis();
    long nextUpdateTimeMillis = currentTimeMillis * DateUtils.MINUTE_IN_MILLIS;
    

    Maybe you meant for the alarm to go off in one minute:

    long nextUpdateTimeMillis = currentTimeMillis + DateUtils.MINUTE_IN_MILLIS;
    

    Anyway first use:

    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 
                              System.currentTimeMillis() + 10000, 
                              5000,
                              pendingIntent);
    

    To confirm your setup is correct, if so you need to recalculate your nextUpdateTimeMillis.

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

Sidebar

Related Questions

I am trying to set a repeating alarm in android that eventually will go
I am trying to set up an alarm that will run in the background
I'm trying to set alarm for calendar events that are inserted through my application.
I am trying to use this to set an alarm that goes off everyday.
I'm trying to update the alarm time that is set when calendar events are
I'm trying to set up an alarm receiver right after booting. Therefore, i have
I'm trying to make an alarm clock in which you can set multiple times.
Trying to set it so if a certain condition is met then one of
I am trying here to set an alarm. I am located in Montréal, so
I'm trying to implement an Android app that needs to alarm (or to alert)

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.