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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:08:17+00:00 2026-06-17T16:08:17+00:00

For online games, it would be great to know if an Android Activity ‘s

  • 0

For online games, it would be great to know if an Android Activity‘s onDestroy() is only called because Android is going to re-create it (e.g. device rotation) or if the user opted to exit the game.

My plan was to set a flag in the Activity‘s onSaveInstanceState() when Android is probably re-creating the Activity:

private boolean mDestroyedForReCreation;
...
protected void onSaveInstanceState() {
    ...
    mDestroyedForReCreation = true;
}

If you did this, you can check mDestroyedForReCreation in onDestroy():

  • If the flag is set (true), don’t dismiss the user from the online game.
  • If the flag is not set (false), dismiss the user from the online game as he did voluntarily exit the game.

Is that a correct approach? And if yes, is it recommended or is there any better solution? I hope so because I don’t really like that solution …

  • 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-17T16:08:18+00:00Added an answer on June 17, 2026 at 4:08 pm

    I suggest you to remove such kind of game logic from activity’s life cycle. Create a Service. If no one binded – all activities are dead. Is someone binded – keep working.

    If you do not want to create service, you can use onRetainNonConfigurationInstance method. Here is example.

    You should use onRetainNonConfigurationInstance because it is called by the system, as part of destroying an activity due to a configuration change, when it is known that a new instance will immediately be created for the new configuration. onSaveInstanceState called when android going to kill activity and maybe restore it sometimes or maybe not ).

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

Sidebar

Related Questions

I would like to create a multiplayer online game (tic-tac-toe/chess) and i am not
I've written some simple online games using purely HTML5 and JavaScript. Nothing fancy, no
For an online game (MMORPG) I want to create characters (players) with random strength
I'm creating an online game in PHP where users can create playable characters. Each
I'm making a small online game, where (what do you know) there'll be multiple
I'd like to throw together a small game and put it online. It would
Suppose you created an online game in HTML5/JavaScript. All the code would be downloaded
I am developing a web-based Pokemon Online game. Since it is online, I would
i want to create an online 3d game of roads and city buildings (supposed
I have a table called games in which will have games.id, games.name and games.modus

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.