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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:26:48+00:00 2026-06-02T09:26:48+00:00

I’m trying to get a notification to fire at a specific time. It occurs

  • 0

I’m trying to get a notification to fire at a specific time. It occurs to me that I wouldn’t have to use an Alarm Manager since I have the “alCal” variable that sets the time. Would it be possible to convert alCal into a Long and use it instead of System.currentTimeMillis(); as the fireTime variable? If so, how would I convert alCal into a Long? Here’s my current code:

            //---use the AlarmManager to trigger an alarm---
        AlarmManager aMan = (AlarmManager) getSystemService(ALARM_SERVICE);

            //---get current date and time---
        Calendar alCal = Calendar.getInstance();
        //---sets the time for the alarm to trigger---                       
        alCal.set(Calendar.HOUR_OF_DAY, 23);            
        alCal.set(Calendar.MINUTE, 41);                
        alCal.set(Calendar.SECOND, 00);

        Intent noteIntent = new Intent(this, Splash.class);
        PendingIntent pendI = PendingIntent.getActivity(this, 0, noteIntent, 0);
        long fireTime = System.currentTimeMillis();
        String noteBody = "notification body";
        String noteTitle = "notification title";
        Notification note = new Notification(R.drawable.noteicon, noteTitle, fireTime);
        note.setLatestEventInfo(this, noteTitle, noteBody, pendI);
        note.defaults = Notification.DEFAULT_SOUND;
        noteman.notify(uniqueID, note);
        //---sets the alarm to trigger--- 
        aMan.set(AlarmManager.RTC_WAKEUP, alCal.getTimeInMillis(), pendI); 
        finish();

ok, looks like I can’t convert alCal into a long, so I guess I do have to use an AlarmManager. So given the above code, how do I modify it so that the AlarmManger fires the notification at the specified time? I’m new to Android and Java, so I’m not really seeing the sloution. I would think alCal has to be called somewhere in the new Notification call, but I don’t know how to do that. Eclipse says I can’t just swap fireTime for alCal, so I don’t know what to try next.

  • 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-02T09:26:51+00:00Added an answer on June 2, 2026 at 9:26 am

    It occurs to me that I wouldn’t have to use an Alarm Manager

    Yes, you would.

    since I have the “alCal” variable that sets the time.

    That is a java.util.Calendar object. On its own, it will not execute your code (such as displaying a Notification) at a particular time.

    Would it be possible to convert alCal into a Long and use it instead of System.currentTimeMillis(); as the fireTime variable? If so, how would I convert alCal into a Long?

    Call getTimeInMillis().

    Bear in mind that your code is not “Setting a notification to fire at a specific time in Android”. It will display a Notification immediately, plus set an alarm to invoke an activity at a certain time in the future.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.