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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:25:09+00:00 2026-06-16T03:25:09+00:00

I have used the following code to set alarmmanager for only one time every

  • 0

I have used the following code to set alarmmanager for only one time every days, I’d like to have 2 different time to set, so 2 times every days.

My code:

Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 10);
calendar.set(Calendar.MINUTE, 35);
calendar.set(Calendar.SECOND, 0);    AlarmManager am = (AlarmManager)     getApplicationContext().getSystemService  (Context.ALARM_SERVICE);
PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(getApplicationContext(),     AlarmReceiver.class),      PendingIntent.FLAG_UPDATE_CURRENT);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),     AlarmManager.INTERVAL_DAY, pi);
  • 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-16T03:25:10+00:00Added an answer on June 16, 2026 at 3:25 am

    You can use an interval of AlarmManager.INTERVAL_DAY / 2 :

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 10);
    calendar.set(Calendar.MINUTE, 35);
     calendar.set(Calendar.SECOND, 0);    
    AlarmManager am = (AlarmManager)getApplicationContext().getSystemService  (Context.ALARM_SERVICE);
    Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class);
     PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(), 0, intent,      PendingIntent.FLAG_UPDATE_CURRENT);
     am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),        AlarmManager.INTERVAL_DAY / 2, pi);
    

    but if the time of the day in which you fire your alarm matters you can use two calendar objects :

    Calendar cal1 = Calendar.getInstance();
    cal1.set(Calendar.HOUR_OF_DAY, 12); //midday
    cal1.set(Calendar.MINUTE, 00);
    cal1.set(Calendar.SECOND, 00);
    
    Calendar cal2 = Calendar.getInstance();
    cal2.set(Calendar.HOUR_OF_DAY, 18);//8pm for example
    cal2.set(Calendar.MINUTE, 00);
    cal2.set(Calendar.SECOND, 00);
    

    and set your alarm manager :

    am.setRepeating(AlarmManager.RTC_WAKEUP, cal1.getTimeInMillis(),cal2.getTimeInMillis(), pi);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the following code to set cookie and then redirect. String level=(String)
I have used the following code several times before, and have recently found it
How to set underline text on textview ? I have used following code but
Hello every body I have used following code in my jpa project for working
I have used the following piece of code to set defailt value of a
I have used following code to convert string to json and parse it. String
i have used following code to repeat a process creation/close iteratively dim vProcessInfo as
I have used following code to create a simple PDF file. It executes fine
I have used the following code to pick up an image from phone's gallery:
I have used the following code in a number of applications to load .DLL

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.