Initializing OpenFeint for Android outside the main Application

Posted by Ef Es on Game Development See other posts from Game Development or by Ef Es
Published on 2012-04-10T18:31:44Z Indexed on 2012/04/10 23:45 UTC
Read the original article Hit count: 279

Filed under:
|

I am trying to create a generic C++ bridge to use OpenFeint with Cocos2d-x, which is supposed to be just "add and run" but I am finding problems.

OpenFeint is very exquisite when initializing, it requires a Context parameter that MUST be the main Application, in the onCreate method, never the constructor. Also, the main Apps name must be edited into the manifest. I am trying to fix this. So far I have tried to create a new Application that calls my Application to test if just the type is needed, but you do really need the main Android application. I also tried using a handler for a static initialization but I found pretty much the same problem.

Has anybody been able to do it? This is my working-but-not-as-intended code snippet

public class DerpHurr extends Application{  

@Override
public void onCreate() {        
    super.onCreate();   
    initializeOpenFeint("TestApp", "edthedthedthedth", "aeyaetyet", "65462");
}       

public void initializeOpenFeint(String appname, String key, String secret, String id){
    Map<String, Object> options = new HashMap<String, Object>();
    options.put(OpenFeintSettings.SettingCloudStorageCompressionStrategy, OpenFeintSettings.CloudStorageCompressionStrategyDefault);
    OpenFeintSettings settings = new OpenFeintSettings(appname, key, secret, id, options);

//RIGHT HERE
    OpenFeint.initialize(***this***, settings, new OpenFeintDelegate() { });
    System.out.println("OpenFeint Started");    
}   

}

Manifest

<application
    android:debuggable="true"
    android:label="@string/app_name" 
    android:name=".DerpHurr">

© Game Development or respective owner

Related posts about android

Related posts about openfeint