Search code examples
androidachievementsopenfeintunlock

Unlocking achievement in OpenFeint


I'm very new to OpenFeint, actually started integrating it into my game today. I can't understand one simple thing that every OpenFeint using developer should probably know. Here's the example of unlocking an achievement from OpenFeint official tutorial:

new Achievement("achievementID").unlock(new Achievement.UnlockCB () {
  @Override public void onSuccess() {
      MyClass.this.setResult(Activity.RESULT_OK);
      MyClass.this.finish();
  }
  @Override public void onFailure(String exceptionMessage) {
        Toast.makeText( MyClass.this,
                "Error (" + exceptionMessage + ") unlocking achievement.",
                Toast.LENGTH_SHORT).show();
        MyClass.this.setResult(Activity.RESULT_CANCELED);
        MyClass.this.finish();
   }
});

Problem is that I don't want to finish my activity in onSuccess or onFailure, I just don't need to do anything here. If I just leave these two methods codeless, my game freezes an becomes totally unresponsive. What should I do? Thanks in advance.

P.S. How do you create Test Users? I've tryed every email-password combination possible and could not get it to go..


Solution

  • Its generally a good idea to put all your communication with the internet in a AsyncTask. Not everyone has fast internet, so this will make sure the main thread doesn't lock up because of that.

    That being said, I think that the setResult function is used in a startActivityForResult construction. The intent that is created in this way is only sent back to the original class if the activity is finished. So to fix this you would need to put the code in a separate activity.