SFS2X Docs / ExamplesAndroid / introduction
» Android examples
In this section of the documentation we provide a series of brief tutorials on the Android examples distributed as a separate 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.
Unless otherwise noted inside the tutorials:
- all examples are distributed in a single package; the same download link is provided in all the tutorials;
- the main folder of each example in the downloaded package is referenced in the related tutorial using this icon: ;
- all examples require JDK 1.6 or later, the Android SDK, the Android SDK platform 2.2 or later and a configured Android Virtual Device (minimum target version is 2.2) — using Eclipse is highly recommended!;
- the server-side Extensions of those examples which require one have been developed using Eclipse 3.5, but you should be able to use any Java IDE of your choice, provided you use the JDK 1.6 or later.
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:
- 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
- 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;
adb install [path_to_APK_file_on_your_machine]/[file_name].apk
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.