Android

Getting Started With OpenFeint SDK for Android 1.10.2

New in OpenFeint Android SDK Version 1.10.2

android icon green New Feature: GameFeed! GameFeed is a cross platform news ticker that features real-time updates from other players in their OpenFeint network. Using GameFeed, you can deliver news that is directly related to the game your players are playing, while they are playing it.

Prerequisites

The following software should be installed and working before you install OpenFeint Android SDK: ADT 0.9.9 Android SDK Tools Revision 10 or greater Android SDK Platform-Tools Revision 3 or greater A build tool such as Eclipse or Ant

Privacy policy update

As an OpenFeint developer, please keep in mind that you must inform users of your applications: Of all information you and OpenFeint will be collecting from your users and their devices and the uses for which you are collecting that information. What information you will be providing to OpenFeint and what information OpenFeint will be collecting from your users and their devices and how OpenFeint may use that information even if your users do not opt in to the OpenFeint platform. You should implement an appropriate privacy policy to address these and any other privacy-related issues.

Register your android game on the OpenFeint developer site

The OpenFeint Developer Dashboard is the center of activity for developers working with OpenFeint. From here you will create your free developer account, download the OpenFeint Android SDK, and manage server side components of your projects.

  1. Go to the OpenFeint Developer Dashboard
  2. Register or log in Use an email address for your identity with your chosen password. Note: If you are already using an email address to log in as an OpenFeint game player, you will need to use a different email address to register as a developer.
  3. Select an existing game description or register a new one.
  4. Browse basic features. Achievements and leaderboards under the Features tab is a great place to start. Go ahead and define a new achievement or leaderboard as an experiment.
  5. Download the latest OpenFeint Android SDK for Android. Click the Downloads button at the top of the page. Extract the downloaded package into a directory on your development computer.
  6. Locate OpenFeint Documentation and Support Resources. The downloaded SDK includes a reference manual in the doc/index.html directory.

Add GameFeed to your game

To get GameFeed up and running in your game:

  1. Before you integrate GameFeed into your game, make sure youve updated your OpenFeint integration to the current version of OpenFeintAPI.
  2. High Level Integration Overview. To prepare your code for GameFeed, heres what you do:
    • toggle game speed test sampleUpdate your main menu UI and layout to make space for the GameFeed UI element.
      – For Portrait, you will need to clear an approximately 76 pixel high space to fit the game bar. (The actual number of pixels will vary with the screen resolution of the target device.)
      – For Landscape, you will need to clear an approximately 62 pixel high space to fit the game bar. (The actual number of pixels will vary with the screen resolution of the target device.).
    • Include the GameFeed API code
  3. Link against the GameFeed library:
    • In Eclipse:
      Import the GameFeed library into your project:
      Right-click the application project.
      Click Import.
      Click Existing Projects into Workspace..
      Click Next.
      Browse to the directory in which the OpenFeintAPI and GameFeed libraries are stored.
      Click OK.
      If OpenFeintAPI is not yet imported, click its checkbox.
      If GameFeed is not yet imported, click its checkbox.
      Click Finish.
      Build the OpenFeint and GameFeed libraries.
    • In Ant:
      Edit the default.properties file in your game projects directory.
      There should already be an android.library.reference.1 entry for your reference to OpenFeintAPI. Add an android.library.reference.2 entry that points to the GameFeed folder in the unzipped release. If the GameFeed folder is a sibling to your game project folder, it should look like this:
      android.library.reference.2=../GameFeed
  4. Integrate. There is an example of how to use GameFeed in the provided sample application. See MyOpenFeintSample/src/com/openfeint/example/GameFeedPage.java for details. Basically, to integrate GameFeed:
    • Make sure OpenFeint is initialized first (in the onCreate() method of your Application class).
    • in the onCreate() method of the Activity class in which you want to show GameFeed, create a
      Map
      with all the settings you want to configure GameFeed. Take a look at GameFeed/src/com/openfeint/gamefeed/GameFeedSettings for the full set of keys you can configure.
    • Create a new GameFeedView with
      GameFeedView gameFeedView = new GameFeedView(this, your_settings_map);
    • Add gameFeedView to your layout. The easiest way to do this is
      gameFeedView.addToLayout(this.findViewById(R.id.root_layout_id));
  5. Add to your layout: GameFeedView#addToLayout(View) works on LinearLayout, RelativeLayout, and FrameLayout classes. It works best on the FrameLayout class (i.e. if you animate in and out, it wont shift your content around). If your root layout isnt one of these classes, it may be worth adding a FrameLayout at the root of your layout hierarchy and using that as the layout that you add GameFeedView to.
    If you want to position your GameFeedView in a custom way, you should be able to simply call yourLayout.addView(gameFeedView) without any trouble, but be aware that if you go with this implementation, none of the alignment or animation settings will work.
  6. Hiding and showing: Call hide() or show() on your GameFeedView when you want to specifically hide or show it. These methods are necessary if youve enabled the animation setting (see GameFeedSettings.AnimateIn), but if you just want to show and hide the view without animating, you can simply call setVisibility(View.GONE) or setVisibility(View.VISIBLE).
Work with test users

For information about how to use the OpenFeint test users functionality which enables user data accumulated during development and testing to be purged from the server, see http://www.openfeint.com/developers/test-users/

Obfuscate

Obfuscate your code with ProGuard We recommend that you obfuscate your application code before release. For your convenience ProGuard config is integrated with our example. You should download android SDK2.3 or above, it has ProGuard built in. ProGuard integrates easily with Ant but cannot be integrated into the Eclipse build process. Reference http://developer.android.com/guide/developing/other-ide.html for help in setting up an Ant build environment.

Important! Be sure to copy or merge proguard.cfg from OpenFeints example application and place them into your Android projects root directory. Do not use the proguard.cfg that is generated for you.

If you experience any issues co-existing with Eclipse you might want to modify your local.properties file to re-direct the out.classes.dir to the same spot as Eclipse by default:

out.classes.dir=bin/ 

Building with ant debug or ant release will now obfuscate your code as part of the build process. To make a build without obfuscation for whatever reason, simply set the property noobfuscate to true:

ant -Dnoobfuscate=true debug ant -Dnoobfuscate=true release

The Approval Process

When your game is complete, you will probably want to publish it for all the world to see. If you plan to distribute your game through Googles Android Market, make sure that you are prepared to sign up and agree to their terms. Portions of your game that rely on OpenFeint servers for free hosting must meet OpenFeints terms and pass approval. This process is initiated by the Prepare for Submission button on the OpenFeint developer dashboard. Select Android as the platform to be approved, accept the terms and conditions, and hit the submit button.

Learn more about OpenFeint features

Read the the reference manual in the SDK package at doc/index.html. Experiment with the code in the sample app.