Examples (iOS)
Examples (Android)


» Android examples

In this section of the documentation we provide a series of brief tutorials on the Android examples distributed as a specific package on the SmartFoxServer 2X download page.

Most tutorials analyse a single example, describing its objectives, giving an insight into the SmartFoxServer features it wants to highlight and providing the direct link to download the source code, which includes all the assets required to compile and test it (both client and — if existing — server side). If necessary, code excerpts are provided in the tutorial itself, in order to better explain the approach that was followed to implement a specific feature. At the bottom of the tutorial, additional resources are linked if available.

The complexity of the examples is gradually increased with each example building on the code and concepts that are in the previous example. As these are SmartFoxServer 2X examples, the code highlights for each example try to explain the SFS2X concepts as opposed to Android specific code.

Each of the examples contains the client-side source code necessary to run the application in the Android emulator, or an AVD as it is referred to in Android documentation. Instructions on how to set up your development environment are readily available online but a good starting point can be this page.

» Requirements

Unless otherwise noted inside the tutorials:

All the examples make use of the latest version of the SmartFoxServer 2X Java client API available when they have been published. As the API evolve in time (bug fixes, new features), we strongly recommend that, after downloading an example, you overwrite the included API JAR file (SFS2X_API_Java.jar in the source code's lib folder) with the one provided in the latest SmartFoxServer package or patch available on our website.

» Running the examples on a phone

The examples can be run in an Android Virtual Device (emulator) after importing the source code in Eclipse.
In order to run them on an actual device instead, follow these steps:

  1. download and install the Android SDK and the Android USB drivers (Windows only, not needed for other operating systems: http://developer.android.com/sdk/installing.html
  2. modify your Android phone's settings to allow the installation of applications from other sources:
    • under Settings, select Application Settings and then enable Unknown Sources;
    • also under Settings, select SD Card and Phone Storage, and finally enable Disable Use for USB Storage;
  3. for each example locate the /deploy folder (or /deploy/client folder for the examples featuring a server-side extension too): it contains the .apk file which can be run on your device;
  4. open a Terminal window and type the following:

    adb install [path_to_APK_file_on_your_machine]/[file_name].apk

  5. if required by the specific example, install the server-side Extension and restart SmartFoxServer 2X;
  6. the application is now ready for your use and enjoyment.

We hope these example show you how easy it is to make multiplayer apps with SmartFoxServer 2X for your Android devices. Click on the first example in the sidebar to get started.