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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:59:34+00:00 2026-05-17T23:59:34+00:00

I am developing a multi player game app for the android. One of the

  • 0

I am developing a multi player game app for the android.
One of the participant is acting as the host (the one who created the game instance) and each of the other participants is connecting to the host using bluetooth.

My question is as follows, this host has some threads running in order to communicate and holds all the open connections. I’ve read that my Activities can be destroyed temporary and restored later and I should use the onSaveInstanceState mechanism for that. However, I am talking about an app that is acting as a “server” for the game and it has open connections and threads that serves the other clients, what happens to these connections and threads if the OS is deciding to destroy my activity? Are they terminated? If so what would be the recommended pattern in order to implement this properly, How can I keep a connection on the onSaveInstanceState bundle? it is not serializable. The same goes for the threads, do I need to recreate and destroy them upon destroy and when the activity is restored?? if I hold all this state in some static class that represents the game state? If I do so, will then the OS not destroy my threads/connections?

I looked at the sample Bluetooth chat that comes with the SDK and I so there’s no handling of the onSaveInstanceState so it is very unclear what should I do.

Thank you!

  • 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-17T23:59:35+00:00Added an answer on May 17, 2026 at 11:59 pm

    what happens to these connections and threads if the OS is deciding to destroy my activity?

    If you created those threads in an activity, you better stop those threads, or you will leak them.

    How can I keep a connection on the onSaveInstanceState bundle?

    You can’t.

    The same goes for the threads, do I need to recreate and destroy them upon destroy and when the activity is restored?

    If they were started by the activity, then, yes, please.

    if I hold all this state in some static class that represents the game state? If I do so, will then the OS not destroy my threads/connections?

    Please put your server logic (threads, connections, server-side game logic) in an Android service. Please use startForeground() to keep that service going, putting a Notification in the status bar along the way so the user has an easy way to get back to the activity that allows them to stop your service.

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

Sidebar

Related Questions

im developing a multi-player card game that needs the clients to communicate with each
I'm currently thinking of developing chess code with multi-player facility connected and played via
I am developing a multi-threading application, which is deadlocking. I am using Visual C++
I'm in the process of developing a multi-tiered financial processing application in Java using
I've been developing a small card game which is called Tarneeb. The game itself
I want to start this as a hobby in developing a desktop game. I
We're developing a silverlight multiplayer game using TCP connections. We have all of our
I'm thinking about developing online multiplayer social game. The shared state of the world
In a multiplayer game I'm developing, we have a few values that are floating
There are 4 months since I stopped developing my Silverlight Multiplayer Chess game. alt

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.