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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:24:24+00:00 2026-05-24T13:24:24+00:00

When I press the back button, while my app’s running, the onPause method gets

  • 0

When I press the back button, while my app’s running, the onPause method gets called, but the onSaveInstanceState isn’t. Then, if I enter my app again, I receive a call to onCreate, which will re-run my initialization logic.

I would like to save the state, so I can restore it when the user enters the app again, however I’m not sure how to go about this. What use will the onCreate‘s Bundle be to me, since in onPause I can only save data through SharedPreferences? Or I shouldn’t rely on the Bundle at all, and just reinitialize from the SharedPreferences?

How could the reinitialization be handled best?

EDIT: I would prefer if the changes could persist only until the app is killed. Only for the application’s lifetime.

  • 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-24T13:24:25+00:00Added an answer on May 24, 2026 at 1:24 pm

    From the onSaveInstanceState API Page

    If called, this method will occur before onStop(). There are no guarantees about whether it will occur before or after onPause().

    As long as your activity is being killed and you have overridden the onSaveInstanceState correctly then it should be fired.

    As for your recent edit (from the same API page)

    Called to retrieve per-instance state from an activity before being killed so that the state can be restored in onCreate(Bundle) or onRestoreInstanceState(Bundle) (the Bundle populated by this method will be passed to both).

    onSaveInstanceState is best used for persisting state when an activity is killed, not so much just for storing state for the application’s lifetime.

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

Sidebar

Related Questions

this is my flow navA-> navB->navC then when user press NavC back button he
when I press the Maximize button on my WPF app, all the controls therein
If I open a solution then press CTRL + F and select Quick Find,
My application uses GPS updates while it is running and I would like that
I need to put a Notification in the Status bar while my app is
How to handle a back button in an activity? I have some buttons. If
On IE when user hits back button they get the classic IE webpage has
I have a button in my app which leads to the UpdateActivity. This activity
If I press Ctrl + B that ought to give me ASCII code 2,
When I press F5 in Visual Studio 2008, I want Google Chrome launched as

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.