Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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">
share|improve this question
add comment

1 Answer

You're not going to be able to initialize OpenFeint without having an application context and respecting the Android life cycle. It needs a context and it needs to be done in onCreate(). To my knowledge, there is no way around that.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.