开发者

How to add leaderboard feature of OpenFeint in Android?

I am developing a game in Android, by extending a class with view. I have integrated OpenFeint in it by studying the tutorial provided on OpenFeint site url is(http://support.openfeint.com/dev/getting-started-with-of-android-1-10-2-integrate-openfeint-in-your-game/), but I am not able to add a leaderboard f开发者_开发百科eature in my app. How can I do that?

My game class is like this:

public class GameActivity extends Activity {

Intent i;

  Grapic g;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);


        setContentView(new Grapic(this));

and Grapic is a class which extends view and where scoring is done with touch events.


i solved problem by myself
The link http://support.openfeint.com/dev/getting-started-with-of-android-1-10-2-add-openfeint-features-to-your-game/ had the code and first create achievement feature for your game and then leader board in also and refer the code below where you put scores

@Override
        public void onFinish()
        {
             new Achievement("123456").unlock(new Achievement.UnlockCB () {

                 @Override 
                 public void onFailure(String exceptionMessage) {
                   Toast.makeText( getContext(),"Error (" + exceptionMessage + ") unlocking achievement.", Toast.LENGTH_SHORT).show();
                   ((Activity) getContext()).setResult(Activity.RESULT_CANCELED);
                   ((Activity) getContext()).finish();
                 }
               @Override
               public void onSuccess(boolean newUnlock) {
                       // TODO Auto-generated method stub
                       ((Activity) getContext()).setResult(Activity.RESULT_OK);
                       ((Activity) getContext()).finish();

               }
               });
       long scoreValue = Long.parseLong(nit) ;
       Score s = new Score(scoreValue, null); // Second parameter is null to indicate that custom display text is not used.
       Leaderboard l = new Leaderboard("234567");
       s.submitTo(l, new Score.SubmitToCB() {
         @Override public void onSuccess(boolean newHighScore) {                 // sweet, score was posted
                       ((Activity) getContext()).setResult(Activity.RESULT_OK);
                       ((Activity) getContext()).finish();
         }
         @Override public void onFailure(String exceptionMessage) {
           Toast.makeText(((Activity) getContext()), "Error (" + exceptionMessage + ") posting score.", Toast.LENGTH_SHORT).show();
               ((Activity) getContext()).setResult(Activity.RESULT_CANCELED);
               ((Activity) getContext()).finish();
         }
       });
            handler.post(new Runnable() {
                public void run() {
               Intent i=new Intent(new Intent(getContext(),Androidfacebook.class));

               i.putExtra("aman", nit);


                              context.startActivity(i);
                }});                    
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜