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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:06:49+00:00 2026-06-06T18:06:49+00:00

I have been trying to set AlarmManager for Specific date, but it is not

  • 0

I have been trying to set AlarmManager for Specific date, but it is not working at all! When I just use the time it works fine.
Here is the code:

SharedPreferences prefs = PreferenceManager
                    .getDefaultSharedPreferences(this);
            String getEventTime = prefs.getString("EventSTime", "");
            String getEventDate = prefs.getString("EventDate", "");
            Toast.makeText(this, getEventTime + " " + getEventDate,
                    Toast.LENGTH_LONG).show();
            String temp = "", temp2 = "";
            DateFormat dateformat = new SimpleDateFormat("HH:mm");
            DateFormat dateformatDate = new SimpleDateFormat("dd-MM-yyyy");
            try {
                temp = dateformat.format(dateformat.parse(getEventTime));
                temp2 = dateformatDate.format(dateformatDate
                        .parse(getEventDate));
                Toast.makeText(this, temp + " " + temp2, Toast.LENGTH_LONG)
                        .show();

            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            String getEventTimeSubStringHour = temp.substring(0, 2);
            String getEventTimeSubStringMinute = temp.substring(3, 5);
            String getEventDateSubStringDay = temp2.substring(0, 2);
            String getEventDateSubStringMonth = temp2.substring(3, 5);
            String getEventDateSubStringYear = temp2.substring(6, 10);
            Toast.makeText(
                    this,
                    getEventTimeSubStringHour + " "
                            + getEventTimeSubStringMinute + " "
                            + getEventDateSubStringDay + " "
                            + getEventDateSubStringMonth + " "
                            + getEventDateSubStringYear, Toast.LENGTH_LONG)
                    .show();
            hourOfDay = Integer.parseInt(getEventTimeSubStringHour);
            minute = Integer.parseInt(getEventTimeSubStringMinute);
            day = Integer.parseInt(getEventDateSubStringDay);
            month = Integer.parseInt(getEventDateSubStringMonth);
            year = Integer.parseInt(getEventDateSubStringYear);
            int second = 0;
//          calendar.setTimeInMillis(System.currentTimeMillis());
//          calendar.clear();
            //calendar.set(year, month, day);
            calendar.set(Calendar.YEAR, year);
            calendar.set(Calendar.MONTH, month);
            calendar.set(Calendar.DAY_OF_MONTH, day);
            calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            calendar.set(Calendar.MINUTE, minute);
            calendar.set(Calendar.SECOND, second);


            Intent intent = new Intent(MessageService.this,
                    ServiceManager.class);
            PendingIntent callToServiceManager = PendingIntent.getService(
                    MessageService.this, 2, intent, 0);
            AlarmManager alarmToCallServiceManager = (AlarmManager) getSystemService(ALARM_SERVICE);
            alarmToCallServiceManager.set(AlarmManager.RTC_WAKEUP,
                    calendar.getTimeInMillis(), callToServiceManager);

Even after using calendar.set(year, month, day, hourOfDay, minute, second) nothing is happening.
Please Help! Thanks!

  • 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-06T18:06:51+00:00Added an answer on June 6, 2026 at 6:06 pm

    Thanks to Eugen for guiding me.
    It turn out to be the problem of Value, Indeed I was storing June as 7th Month instead of 6th. I was adding 1 to the month and it was making problem. Now I have fixed it and it is working fine now.

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

Sidebar

Related Questions

I have been trying to set-up Maven for use in our dev department but
I have been trying to get SqlCacheDependency working. I think I have everything set
I have been trying to set-up my recently reimaged workstation for working with one
I have been trying to set the value of a hidden input by using
For while I have been trying to set the Page Scaling of Excel page
for around 5 consecutive days i have been trying to set up my computer
I have been trying out the MoreLikeThis Bundle to bring back a set of
I have been trying all afternoon to get the jQuery Sifr Plugin ( http://jquery.thewikies.com/sifr/
I have been trying to set up Titanium and Android for 3 days. Still
I have been trying to set up a program that sends a push notification

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.