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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:56:49+00:00 2026-06-03T10:56:49+00:00

Its about a small android application that will take hours as input from user

  • 0

Its about a small android application that will take hours as input from user for every day of week and turn on / off blue tooth device accordingly for the respective day regardless of the “Date”. i.e the code should only check the day, hour and minute. i have used following code (for testing purpose for today i.e Friday) but it do not triggers the alarm.

//..........setting calender for MyAlarmService
       Calendar cur_cal = new GregorianCalendar();
       cur_cal.setTimeInMillis(System.currentTimeMillis());
       Calendar cal = new GregorianCalendar();
       cal.add(Calendar.DAY_OF_YEAR, cur_cal.get(Calendar.DAY_OF_YEAR));
       cal.set(Calendar.HOUR_OF_DAY, 11);
       cal.set(Calendar.MINUTE, 5);
       cal.set(Calendar.SECOND, 0);
       cal.set(Calendar.MILLISECOND, cur_cal.get(Calendar.MILLISECOND));
       cal.set(Calendar.DATE, cur_cal.get(Calendar.DATE));
       cal.set(Calendar.MONTH, cur_cal.get(Calendar.MONTH));
       // here it m setting the "Today"
       cal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); 

       Intent myIntent = new Intent(AndroidAlarmService.this, MyAlarmService.class);
       pendingIntent = PendingIntent.getService(AndroidAlarmService.this, 0, myIntent, 0);
       AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
       alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);

when i remove the statement
cal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);

The AlarmService triggers perfectly “Today” on the time specifed above i.e 11:05 AM

What am i doing wrong?

  • 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-03T10:56:52+00:00Added an answer on June 3, 2026 at 10:56 am

    found a work around as follows.

     //..........setting calender for Friday
    
    
           Calendar calFri = new GregorianCalendar();
           calFri.add(Calendar.DAY_OF_YEAR, cur_cal.get(Calendar.DAY_OF_YEAR));
           calFri.set(Calendar.HOUR_OF_DAY, friHrInt);
           calFri.set(Calendar.MINUTE,friMinInt);
           calFri.set(Calendar.SECOND, 0);
           calFri.set(Calendar.MILLISECOND, cur_cal.get(Calendar.MILLISECOND));
           calFri.set(Calendar.DATE, cur_cal.get(Calendar.DATE));
           calFri.set(Calendar.MONTH, cur_cal.get(Calendar.MONTH));
    
           days = 13 - calFri.get(Calendar.DAY_OF_WEEK); // how many days until Sunday
           calFri.add(Calendar.DATE, days);
    
         //..........setting calender for Saturday
    
    
           Calendar calSat = new GregorianCalendar();
           calSat.add(Calendar.DAY_OF_YEAR, cur_cal.get(Calendar.DAY_OF_YEAR));
           calSat.set(Calendar.HOUR_OF_DAY, satHrInt);
           calSat.set(Calendar.MINUTE,satMinInt);
           calSat.set(Calendar.SECOND, 0);
           calSat.set(Calendar.MILLISECOND, cur_cal.get(Calendar.MILLISECOND));
           calSat.set(Calendar.DATE, cur_cal.get(Calendar.DATE));
           calSat.set(Calendar.MONTH, cur_cal.get(Calendar.MONTH));
    
           days = 14 - calSat.get(Calendar.DAY_OF_WEEK); // how many days until Sunday
           calSat.add(Calendar.DATE, days);
    

    and then i use separater alarm service for these days as follows

     //.........................The Following will make the alarm go off on friday......................................
    
    
               Intent myIntentFri = new Intent(AndroidAlarmService.this, FriOffAlarmService.class);
               pendingIntentFri = PendingIntent.getService(AndroidAlarmService.this, 0, myIntentFri, 0);
               AlarmManager alarmManagerFri = (AlarmManager)getSystemService(ALARM_SERVICE);
               //alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent2);
               alarmManagerFri.setRepeating(AlarmManager.RTC_WAKEUP, calFri.getTimeInMillis(),interval, pendingIntentSun);
    
               //.........................The Following will make the alarm go off on saturday......................................
    
    
               Intent myIntentSat = new Intent(AndroidAlarmService.this, SatOffAlarmService.class);
               pendingIntentSat = PendingIntent.getService(AndroidAlarmService.this, 0, myIntentSat, 0);
               AlarmManager alarmManagerSat = (AlarmManager)getSystemService(ALARM_SERVICE);
               //alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent2);
               alarmManagerSat.setRepeating(AlarmManager.RTC_WAKEUP, calSat.getTimeInMillis(),interval, pendingIntentSat);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like a web application to learn things about its environment so that
I know about map/reduce alghoritm and its use. It's using functions that are called
sorry about input mistakes, english its not my mother lang. I have this code
I've been looking into a legacy application with a web-based user interface. Given its
I am writing a small game in android that basically is a turn-based boardgame,
I have a Java library that uses a few things from the Android APIs.
I want to build a small App that will recognize any Bluetooth headset connection
I am wondering that does every brand out there whose manufacturing android phones like
I have about 650 small icons I need to reference in my android project.
I'm talking about the Ibox sort. I.e, user clicks a link and a small

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.