Integrating Open Feint in Android


In one of the previous post we had mentioned how to integrate Scoreloop in Android. This time we would be talking about integrating Open Feint as in our game Balloon Shooter we had used open feint for global scoreboard.

First make an account in Open Feint and add a game to it. You would get a page like this.

Open Feint

Initializing Open Feint:

    OpenFeintSettings settings = new OpenFeintSettings(OPENFEINT_NAME, OPENFEINT_PRODUCT_KEY,
    OpenFeint.initialize(getApplicationContext(), settings, new OpenFeintDelegate() {});

The above code can be used to initialize open feint. The OPENFEINT_NAME is “Balloon Shooter”, OPENFEINT_PRODUCT_KEY is “Product  key”, OPENFEINT_PRODUCT_SECRET is “Product Secret” and  OPENFEINT_CLIENT_ID is “Client Application ID”. You can call this in oncreate or while displaying a high score screen. In balloon shooter we initialize open feint when we open the high score screen.

Open Screen:

This is easy. This will open the score screen of open feint:;

Post Score:

Before a score can be posted we would have to make a leaderboard. Here is a screen from balloon shooter

Open Feint Leaderboard

Here you can see the two leaderboards which are used in balloon shooter – Accuracy and Total Balloon Hits. Associated with every leaderboard we have a “Unique ID” which open feint automatically assigns while creating it. We use the unique id to update the leaderboard from our code.

void PostScore(int score,int leaderboardId){
    long scoreValue = (long) score;
    Score s = new Score(scoreValue, null); // Second parameter is null to indicate that custom display text is not used.

    Leaderboard l = new Leaderboard(leadboardId);  // Get the leaderboard in which score has to be updated

    s.submitTo(l, new Score.SubmitToCB() {
    public void onSuccess(boolean newHighScore) { // score was posted
       Toast.makeText(AndroidGame.this,"Score Posted",Toast.LENGTH_SHORT).show();
    public void onFailure(String exceptionMessage) {
         Toast.makeText(AndroidGame.this, "Error (" + exceptionMessage + ") posting score.", Toast.LENGTH_SHORT).show();

First we make a score object with the (long) score and if we don’t want any special text to be displayed with the score then we leave the second argument as null. Then we make a leaderboard object using the unique id from open feint page. Then we submit the score using score.SubmitTo() where we pass the leaderboard object and also instantiate SubmitToCB overriding the success and failure methods. In the Toast command mentioned above we are using AndroidGame.this because that is the name of the activity.  That’s basically it for posting score.

In Balloon Shooter we wanted to show accuracy as percentage. For that we have to set display text in score object. Here is an example.


Our score was percentage in long format, so we just divided it by 100. For example if a person had shot 325 balloons in 1000 attempts then the score would be (325/1000)*100*100 which is 3250. This value is updated in open feint. But for display text we divided it by 100 and concatenated it with the “%” sign which for the above example is 32.5%. The second line is option the “allowWorseScores” which allows worse scores to be updated in open feint. For example if initially 10 was updated in OpenFeint and then a value of 5 was put in then if allowWorseScores is not true than 10 would not be replaced; else the latest value would be updated in open feint.


 android:theme="@style/OFNestedWindow" />
 android:theme="@style/OFNestedWindow" />
 android:theme="@style/OFNestedWindow" />
 android:theme="@style/OFNestedWindow" />

Insert the above in the android project manifest file inside the <application> tag.

Importance of Local Scoreboard:

It is always good to have a local scoreboard either stored in sharedpreferences or using a txt file. In balloon shooter and polar we used sharedpreferences for local scoring. It is good to have local scoreboard because most of the time people don’t like to fetch it from the internet and sometimes they don’t have access to the internet. Another use is that if later we want to migrate to a different global scoreboard like scoreloop then instead of updating score from sharepreferences to openfeint we can just update them in scoreloop. So basic game scoring logic won’t change, just the final update functions would be wrapping scoreloop implementation instead of openfeint.

That is how we can add a simple global scoreboard using open feint in an android game.

If you have any query/suggestions please put them in comments and we would try to answer them.

Thank you for the patience.

Tagged with: , , , ,
Posted in Tutorials
2 comments on “Integrating Open Feint in Android
  1. Yasith says:

    After using both Scoreloop and Openfeint, would you mind making a post comparing them ?

    • DTAdmin says:

      We thought of putting comparitive analysis but then we realized we havent used scoreloop/open feint as extensively as to decide fairly which is better.

Try our games

Error: Twitter did not respond. Please wait a few minutes and refresh this page.