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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:01:32+00:00 2026-05-17T00:01:32+00:00

I am using SmartFoxServer for a multiplayer game. I have it working fine when

  • 0

I am using SmartFoxServer for a multiplayer game. I have it working fine when it loads up in the main chat room. In my app you an create new game rooms and when you click on one it launches a new activity and enters that room. It appears I have to connect to the server again after that. Then I get already logged in error.

How can I maintain the smartfox client throughout my activities?

  • 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-17T00:01:33+00:00Added an answer on May 17, 2026 at 12:01 am

    You can override the Application class and make your server reference a static public variable which will be available from any Activity using ((YourApplication)getApplication()).yourStaticServerReference.

    To override your Application class, follow the following steps :

    • Create a class extending Application, let’s call it com.yourpackage.YourApplication

      package com.yourpackage;
      
      
      import android.app.Application;
      
      
      public class YourApplication extends Application {
          public static SmartFoxServer smartFoxServer;
      
      
      
          @Override
          public void onCreate() {
              smartFoxServer = initSmartFoxServer(); // I don't know SmartFoxServer's API so let's imagine you implement this somewhere in the Application class.
              // Now the smartFoxServer field is like a global variable visible in all your Activities using ((YourApplication)getApplication()).smartFoxServer
          }
      }
      

    • In your application manifest you have to edit the application declaration :

      <application android:icon="@drawable/icon" android:label="@string/app_name"
              android:name="com.yourpackage.YourApplication">
      

    If you often access the smartFoxServer object, you can even use java 1.5 static import feature :

    import static com.yourpackage.YourApplication.smartFoxServer;
    
    public Activity myActivity {
        public void anyMethod() {
            // Thanks to the static import, smartFoxServer is directly accessible, without calling getActivity().
            smartFoxServer.doSomething();
        }
    }
    

    I wrote this directly here so there might be some things wrong… I will check this in more details when the kids let me more than 2 minutes of free time 😉

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

Sidebar

Ask A Question

Stats

  • Questions 545k
  • Answers 545k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I would advise against using the backspace key, since that… May 17, 2026 at 9:02 am
  • Editorial Team
    Editorial Team added an answer (Note: I'll assume that by "decode and dispatch" you mean… May 17, 2026 at 9:02 am
  • Editorial Team
    Editorial Team added an answer Non static properties (alias fields, alias member variables) have their… May 17, 2026 at 9:01 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Using online interfaces to a version control system is a nice way to have
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using Core Data. Let's say we have models for Team and Player. Assume: -Each
Using a site like StackOverflow as an example: I have a table of users,
Using gcc 4.4.3 c89: I am just working on the following code below: I
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button

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.