Platform: OpenFeint Android SDK 1.7.1

Readme.html for OpenFeint Android SDK 1.7.1
Release date 2.2.2011
Release Notes Copyright (c) 2009-2011 Aurora Feint Inc.
All Rights Reserved.

OpenFeint Android Quick Start Guide


<<Prev Next >>
 

Integrate OpenFeint into your game

OpenFeint can be integrated into an existing Android app or it can be incorporated in your game design from the start. Once you have been through the process of experimenting with OpenFeint features in the sample app using your own product key, many of the steps for adding these features to your own app will seem familiar.

NOTE: The following instructions were tested in Eclipse on the Hello World sample app from the tutorial at http://developer.android.com.
  1. If your application is not already registered as an OpenFeint application:
    1. Go to the OpenFeint Developer Dashboard
      Find it at https://api.openfeint.com/dd
    2. Register or Login
      Use an email address for your identity with your chosen password.
    3. Select an existing game description or register a new one.

  2. Make a backup copy of your project before you start integrating with OpenFeint.
  3. Extract a fresh copy of the OpenFeint Android SDK project into a convenient temporary directory.
  4. Run Eclipse.
  5. Import the OpenFeint Android SDK (the sdk directory of the download) into Eclipse.
  6. Right-click on the project and choose Properties.
  7. Select Android.
  8. Under Library, check the Is Library box.
  9. Import your application as a project into Eclipse.
  10. If they do not already exist, create assets/, gen/, libs/, and res/ directories in the root of your project.
  11. Set your project to use the OpenFeint Api as a library:
    1. Right-click on the project and choose Properties.
    2. Select Android.
    3. Under Library, add the OpenFeintAPI project.
    4. Click OK. A source link to the OpenFeint API should appear in the project tree:
      source link
  12. Edit the AndroidManifest.xml file in your project:
    • Add the following activities inside your <application> tag:
      <activity android:name="com.openfeint.internal.ui.IntroFlow"
      android:label="IntroFlow"
      android:configChanges="orientation|keyboardHidden"
      android:theme="@android:style/Theme.NoTitleBar"/> <activity android:name="com.openfeint.api.ui.Dashboard"
      android:label="Dashboard"
      android:configChanges="orientation|keyboardHidden"
      android:theme="@android:style/Theme.NoTitleBar"/>
      <activity android:name="com.openfeint.internal.ui.Settings"
      android:label="Settings"
      android:configChanges="orientation|keyboardHidden"
      android:theme="@android:style/Theme.NoTitleBar"/>
      <activity android:name="com.openfeint.internal.ui.NativeBrowser"
      android:label="NativeBrowser"
      android:configChanges="orientation|keyboardHidden"
      android:theme="@android:style/Theme.NoTitleBar"/>
    • Add the following permissions to AndroidManifest.xml outside of your tag:
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
      
    • To grant OpenFeint the ability to save data in the /sdcard/, which is faster and uses less of the user's built-in flash memory, add the following to the AndroidManifest.xml:
       <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    • To allow OpenFeint to retrieve the logged-in user's email address from Phone SDK version 5 or above so that the user does not have to type the email address in when creating an account, add the following to the AndroidManifest.xml:
      <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  13. Refresh (File->Refresh) the project so that the items you added appear.
  14. Initialize OpenFeint in the onCreate() method of your Application object:
    1. If you haven't overridden the application object:
      1. Create a class that extends android.app.Application
      2. In AndroidManifest.xml, be sure to set the android:name attribute of your <application> element to the name of your application class. For example, in the OpenFeintExample project, the android:name of the <application> element is set to ".MyApplicationClassName".
    2. Construct your OpenFeint settings object using the game name, game ID, game key, and game secret of your game as defined on the OpenFeint developer site:
      • The values can be set in the class definition of the source code of your Application:
        static final String gameName = "Name of your application";
        static final String gameID = "gameID";
        static final String gameKey = "gameKey";
        static final String gameSecret = "gameSecret";
        For example, in the sample application, you could add these lines in src/com.openfeint.example/OpenFeintApplication.java after:
        public class OpenFeintApplication extends Application {
        
        Note: You must provide your game's name, key, secret, and id to
        OpenFeintSettings. You can find these in the developer dashboard at
        https://api.openfeint.com/dd. For instructions on retrieving your application settings, click here.
      • Use the variables you defined to construct your settings object. This can be done in the onCreate() method of your main activity:
        OpenFeintSettings settings = new OpenFeintSettings(gameName, gameKey, gameSecret, gameID);
        
        For example, in the sample application, you could add this line into the onCreate() method in src/com.openfeint.example/OpenFeintApplication.java.
    3. Initialize OpenFeint in the onCreate() method of your application by adding the the following line into the onCreate() method in your source code:
      OpenFeint.initialize(this, settings, new OpenFeintDelegate() {});
      Make sure you call OpenFeint.initialize() after you've set the values in the settings object.

  15. Run your application.
    On the application's first launch, when it gets to the OpenFeint.initialize() call, it displays an OpenFeint welcome screen over the game screen. This allows the user to log in to OpenFeint or decline OpenFeint. After the first launch of the app, the user's choice is remembered and the OpenFeint welcome screen does not appear.

    At this point, OpenFeint has only been initialized; none of its features have yet been incorporated into your application.