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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:50:08+00:00 2026-05-21T06:50:08+00:00

In my main activity, onCreate I set a textView to the current date. From

  • 0

In my main activity, onCreate I set a textView to the current date. From that activity, I startActivityForResult activity2, where I can change the date. onActivityResult, I set the textView to whatever date was returned.

Now, if you close the main activity and the textView is not the current date. The next time you open it (from the button on home screen or app drawer), I would like it to set the textView to the current date.

After it opens for the first time, the next time you open it, it doesn’t hit onCreate. I’ve tried using onResume however this prevents activity2 onActivityResult from changing the date.

  • 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-05-21T06:50:09+00:00Added an answer on May 21, 2026 at 6:50 am

    How about something like this:

    First of all, create an onSaveInstanceState(Bundle) method and save the current contents of the date TextView to it. This is called before Android stops, hides, or destroys your activity.

    When you start activity2, your onStop() of activity1 will be called. In there, set a flag to indicate whether or not onStop() is called due to you starting a new activity (make the intent for activity2 a member, not local variable for this). Ensure you save this flag in onSaveInstanceState of activity1.

    Implement onRestoreInstanceState(Bundle) in activity1, and restore to local variables the date and flag values.

    Finally, in onResume of activity1, check the flag – it you are resuming because you are returning from activity2, do not change the TextView since that will be set in onActivityResult, otherwise, you can safely restore the saved date value.

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

Sidebar

Related Questions

The main activity includes some variables with set values. I created a sub-activity with
Newb question. How can you know what the main launch Activity is? Learning Android.
I have a widget that supposed to call an Activity of the main app
Code: public class SMH extends Activity { public void onCreate(Bundle b) { super.onCreate(b); setContentView(R.layout.main);
I am trying to send a message to my main activity from an Async
I called my main activity Main, and Eclipse created Main.java and res/layout/main.xml for the
i have main activity in which i have Four menus. and i have one
I'm having difficulties handling multiple instances of my root (main) activity for my application.
I tried using the following code in .java(main activity): final ImageView diskView1 = (ImageView)
I have a design of activities like this I have one main activity and

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.