Integration of some features of the Scoreloop social gaming network into an Android application

    Tables of records appeared in games many, many years ago. At first they were very simple, remember, for example, games for consoles with three-character player names.

    Over time, the record tables became more complicated, the results became possible to publish on the Internet to see yourself in the global list.

    Nowadays, in the days of the Internet, social networks and mobile devices, high score tables have grown into entire social gaming networks.

    Below I’ll talk about integrating one of these social gaming networks called Scoreloop into my Android application.

    Key features

    Scoreloop provides an SDK for Android, Bada, iOS and Windows Phone 7 applications, giving you access to the following features:
    • Points and results tables. The player can collect points during the game that are sent to the server and can then be displayed as a global table, the best points of the day, a table based on nationality, based on geographic location or a table among the player’s friends.
    • Fights. A player can challenge another player to a duel: the first competitor, having gained a certain amount of points, sends the result to the server, setting a reward for the duel (a certain amount of money in the in-game currency). Another person can accept the challenge and try to beat this result. The winner receives a reward.
    • Awards and achievements. The player can receive rewards in the in-game currency for certain achievements (find and kill all monsters at a level, complete a level without killing a single monster, etc.)
    • Social posts. The player can send emails to MySpace, Facebook and Twitter about certain events, such as getting a certain number of points, creating a duel, winning a duel, receiving a reward, game information or an invitation to join Scoreloop.
    • Activities. A player can receive messages about events that have occurred with his friends, or with a player passing the same level as him. For example: "Player001 received 50 points in the game SLDemoCore."
    • News. The developer can show the news directly to the player within the game.
    In our game, we will try to integrate the points and the table of the best results (Leaderboard in terms of Scoreloop).

    Result table

    Step 1. Register on the site (without this, nothing will work out) and download the SDK (the link works only if you are logged in)

    Step 2. Add our application, get the game id and secret code for it.

    You can go further in two ways - use the CoreSocial SDK and do everything by hand, or use ScoreloopUI and get a ready-made UI for the results table, etc. We will go the second way.

    Step 3. Unzip the SDK to some directory.

    I assume that you are using Eclipse to develop your application. Open the ScoreloopUI project from the SDK using the command File -> Import -> Existing Projects Into Workspace.

    Then connect the ScoreloopUI project to your project as a library (right-click on your game project, select 'Properties', select 'Android', click the 'Add' button in the 'Library' section, find the ScoreloopUI project and select it).

    You also need to connect the scoreloop-core.jar library to your project (Project -> Properties -> Libraries -> Add external JAR)

    Step 4. Set the necessary permissions for your application.

    Obviously, the application will need access to the Internet (INTERNET). Why READ_PHONE_STATE is needed, I don’t know for sure, and READ_CONTACTS can be omitted if you set ui.feature.address_book = false in the file.

    Step 5. Specify the ScoreloopUI activity that your application will use.

    Step 6. Getting the file Go

    back to the web panel, configure the game properties (Game Properties tab), then click on the “Get” link on the same page and save the file in the / assets of your project.

    Step 7. Initializing and destroying the Scoreloop framework.

    To initialize and destroy the framework classes, the ScoreloopManagerSingleton class is used. Please note that the operations described below must be performed in the application class, and not in the activity. When you create an application class (if you do not already have one), be sure to include the name of the application class in the "application" tag of your manifest.


    ScoreloopManagerSingleton.init (this, "secret code obtained through the web interface");


    ScoreloopManagerSingleton.destroy ();

    In addition, the SDK strongly recommends that all calls be implemented within the main UI stream. If streams are used in your application, it is recommended that you use the Android Handler objects ( and call the ScoreloopUI API from the main stream.

    Step 8. Sending the game result to the server.

    Your activity must implement the OnScoreSubmitObserver interface. It consists of the onScoreSubmit method, which will be called after the points are sent to the server (it is obvious that this operation takes time and it is impossible to block the UI stream for such a time).

    We register activity as an observer of the results of sending:

    ScoreloopManagerSingleton.get (). SetOnScoreSubmitObserver (this);

    We send points to the server:

    Double scoreResult = 1450.0;
    ScoreloopManagerSingleton.get (). OnGamePlayEnded (scoreResult, null);

    In the onGamePlayEnded method, the second parameter is the game mode (for example, easy, difficult, etc.). Since we did not configure the modes through the web interface, we pass null.

    Step 9. Displaying a table of results

    With this, everything is quite simple:

    startActivity (new Intent (this, LeaderboardsScreenActivity.class));

    Here's what it looks like:


    Scoreloop for using its service requires that the icon of your application has a small Scoreloop logo on top of the main image, such as here:

    This is supposedly so that users can immediately see that this application is integrated with Scoreloop and start downloading it with terrible force but we know ...


    If any questions remain unclear, I will try to answer in the comments. In addition, the SDK includes detailed and very clear documentation.

    You can see the integration results described in this article in the Qbrix game ( link to the Market , link to .apk ):

    PS I take this opportunity to say thanks to the authors of the articles about the integration of AdMob and ACRA into the Android application. These guides saved me several hours of development.

    Also popular now: