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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:46:39+00:00 2026-06-11T03:46:39+00:00

I need to set a repeating alarm that will once fired, launch a notification.

  • 0

I need to set a repeating alarm that will once fired, launch a notification.

Steps:

  1. I have an interface that takes some date details (Just had a thought, maybe I should be launching an intent to display the “set alarm” feature). The product of the details is a date time string that needs to be fed into an alarm method.
  2. When setting an alarm I need to create a reference to it so it can be deleted by the user. (Or maybe not, what is best practice? Maybe users can only delete an alarm from the “alarm” section)
  3. When the alarm goes off a notification will be created.

I’m uncertain of how the alarm system works. The alarm probaly should be silent, maybe with vibration. Is that straight forward to setup?

Do I need a service or will a broadcast reciever do the job?

Basically I just need a few pointers. Am I thinking about this correctly? Is there a tutorial out there (I haven’t found anything). Thanks in advance.

  • 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-11T03:46:40+00:00Added an answer on June 11, 2026 at 3:46 am

    Here is a walkthrough on how I use an AlarmService in my app.

    1. Set up an AlarmManager to fire in x minutes.

    2. In response to the alarm, start a service.

    3. Create your notification and have your service set itself up with a new Alarm to fire again in another x minutes.

    4. The service shuts itself down.

    1.

        Intent alarmIntent = new Intent(this, MyAlarm.class);
        long scTime = 60* 10000;// 10 minutes
        PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, 0);
        AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
        alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + scTime, pendingIntent);
    

    2.

        public class MyAlarm extends BroadcastReceiver
        {
    
           @Override
           public void onReceive(Context context, Intent intent) {
              Log.d("Alarm Recieved!", "YAAAY");
              Intent i = new Intent(context, InviteService.class);
              context.startService(i);
           }
        }
    

    3.

          public class InviteService extends IntentService
     {
    
      /** 
       * A constructor is required, and must call the super IntentService(String)
       * constructor with a name for the worker thread.
       */
    
      public InviteService() {
          super("InviteService");
      }
    
      /**
       * The IntentService calls this method from the default worker thread with
       * the intent that started the service. When this method returns, IntentService
       * stops the service, as appropriate.
       */
    
      @Override
      protected void onHandleIntent(Intent intent) {
    
                      String ns = Context.NOTIFICATION_SERVICE;
                      NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
    
                      int icon = R.drawable.logo;
                      CharSequence tickerText = "New Invite!";
                      long when = System.currentTimeMillis();
    
                      Notification notification = new Notification(icon, tickerText, when);
                      notification.flags |= Notification.FLAG_AUTO_CANCEL;
                      notification.defaults |= Notification.DEFAULT_VIBRATE;
    
                      Context context = getApplicationContext();
                      CharSequence contentTitle = "Title";
                      CharSequence contentText = "Text";
                      Intent notificationIntent = new Intent(this, Destination.class);
                      Bundle partyBundle = new Bundle();                    
    
                      PendingIntent contentIntent = PendingIntent.getActivity(this, SOME_ID, notificationIntent, 0);
    
                      notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
    
                      int NOTIFICATION_ID = SOME_ID;
    
                      Log.d("NOTIFICATION_ID", "" + NOTIFICATION_ID);
                      mNotificationManager.notify(NOTIFICATION_ID, notification);
    

    4.(In the Same Class)

          Intent alarmIntent = new Intent(this, MyAlarm.class);
          long scTime = 60*1000;//mins
          PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, 0);
          AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
          alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + scTime, pendingIntent);
    
          stopService(intent);
          }
        }
    

    Hope this helps!

    EDIT

    Why use a Service?

    It’s not wise to do much processing in the BroadcastReceiver. Although you can do some processing in the BroadcastReciever, it is safer to do this in a Service, you can find some information in this StackOverflow question BroadcastReceiver vs Service

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

Sidebar

Related Questions

I need to set an alarm at perticular time that repeats given number of
I need Set collection, where its items will be identified by items class. Something
Need to set some attributes of button. For example Checked. I guess it is
I need to set custom alarm tone in my App. Could anyone please just
I need to set the default icon that VS uses for the project to
I am developing alarm application for that I need to invoke alarm repeatedly for
I user sets an alarm it will need to send off an intent to
I need to set a number of alarms that repeat weekly, to automatically put
I need to call identical LINQ queries multiple times that only have differing elements
I am using this code to launch an Alarm. The alarm is set in

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.