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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:41:40+00:00 2026-06-14T20:41:40+00:00

I have a game app that save game status in the onPause() function of

  • 0

I have a game app that save game status in the onPause() function of the game board activity.

That seems very wasteful, because the user might be briefly switching to another app and return to play later. But if they never return, my app could be garbage collected and the status gets lost, so I save it just in case.

I think status gets saved many times for every time it gets read. Is there a better way to lazily save the status when I know they are leaving the app?

Does anybody know of a guaranteed callback that I could use? e.g. if I move the save status code to onDestroy(), it might never get called.

Is there a way to leverage onSaveInstanceState() to 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-14T20:41:41+00:00Added an answer on June 14, 2026 at 8:41 pm

    onPause() gets called when the user switches orientation and when the user navigates away. Both of these actions have the potential for data loss, so saving in onPause() is a good idea, no matter what you’re making (be it a game or an app).

    So no, onPause() is the safest way to ensure data persistence.

    EDIT
    To answer your second question, onSavedInstanceState() is not clear cut

    If called, this method will occur before onStop(). There are no guarantees about whether it will occur before or after onPause().
    http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle)

    So for a game, I would aggressively save the player’s data, and would do so in onPause(). Everything else either has potential to fail or isn’t directly related to the Activity lifecycle.

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

Sidebar

Related Questions

I have Chronometer in my app, that counts game elapsed time. I have save
We have an existing game app that is now defunct and is just sitting
I have a Rails app implementing a game, so it's expected that a player
i have a java game app that uses sockets to communicate with each other.
I have a game app that has the ability to go fullscreen and back
I have this memory game app that I'm working on, trying to learn WP7.
I have an app that must send a game score to someone's Facebook wall,
I have an existing iOS app on the App Store that includes Game Center
I have an game app which occasionally plays sounds. When the phone goes into
I have a game app which is mostly working fine. If a phone call

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.