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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:43:09+00:00 2026-06-01T21:43:09+00:00

I am new to Android programming and face a challenge that probably can be

  • 0

I am new to Android programming and face a challenge that probably can be solved in seconds on this forum.

I am trying to figure out how to enable an application during start up to detect whether the date has changed since it’s last boot.

When the date has changed, I intend to change the value in the textview. However if it hasn’t, the textview wont change. – I know how to create this function however stuck on the date change problem?

I have read on alarmmanager however not sure this is required as it doesn’t need to happen at the specific time only during boot up.

Any advise would be appreciated.

Thanks,

p.s I am creating a basic quote application and want to include a quote of the day page. In order to do this, I need to know whether the date has changed in order for the application to change the quote

  • 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-01T21:43:11+00:00Added an answer on June 1, 2026 at 9:43 pm

    What you will need is this:
    A SharedPreference with a long value describing the last date.
    A Calendar.

    When your Activity starts (in the onCreate() Method seems like a good place for this) you can get a new Calendar. It will have the current date, and you can extract the day:

    Calendar c = Calendar.getInstance();
    int thisDay = c.get(Calendar.DAY_OF_YEAR); //You can chose something else to compare too, such as DATE..
    long todayMillis = c.getTimeInMillis(); //We might need this a bit later.
    

    You then read the possibly saved value from last time and set the calendar to this value, then compare this with today:

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    long last = prefs.getLong("date", 0); //If we don't have a saved value, use 0.
    c.setTimeInMillis(last);
    int lastDay = c.get(Calendar.DAY_OF_YEAR);
    
    if( last==0 || lastDay != thisDay ){
        //New day, update TextView and preference:
        SharedPreferences.Editor edit = prefs.edit();
        edit.putLong("date", todayMillis);
        edit.commit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to Android programming and I've been trying to figure out why
I'm new in Android Programming. I'm trying to write an app that uses USB
I'm very new to Android programming, so this is probably something pretty basic. I
I'm new to android programming, but one thing that I can't seem to get
I'm fairly new to Android programming, so this may be a simple question, but
I am fairly new to Android programming and was wondering how I can get
I'm still new to programming/Java/Android so I'm trying to understand everything I do and
I'm new to Android programming. I've seen different phones with different screen resolutions that
Hi I'm new to android programming, I'm trying to initiate the on click method
I am new to android programming and trying to build a map activity app.

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.