oppo SDK接入

废话不多说 直接上代码
1初始化:GameCenterSDK.init()
2登陆:
 
   
GameCenterSDK.getInstance().doLogin(U8SDK.getInstance().getContext(), new ApiCallback()
{
    public void onSuccess(String content)
    {
        Log.d("U8SDK", "login success . the content:" + content);
        GameCenterSDK.getInstance().doGetTokenAndSsoid(new ApiCallback()
        {
            public void onSuccess(String result)
            {
                try
                {
                    Log.d("U8SDK", "get token success:" + result);
                    JSONObject json = new JSONObject(result);
                    String token = json.getString("token");
                    String ssoid = json.getString("ssoid");

                    String loginResult = OppoSDK.this.encodeLoginResult(token, ssoid);
                        //和服务器交互
 
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            }

            public void onFailure(String content, int code)
            {
                U8SDK.getInstance().onResult(5, content);
            }
        });
    }

    public void onFailure(String content, int code)
    {
        U8SDK.getInstance().onResult(5, content);
    }
});
3支付
    String notifyUrl = params.getExtension();
    PayInfo pay = new PayInfo(params.getOrderID(), "", params.getPrice() * 100);
    pay.setProductName(params.getProductName());
    pay.setProductDesc(params.getProductDesc());
    pay.setCallbackUrl(notifyUrl);
    GameCenterSDK.getInstance().doPay(U8SDK.getInstance().getContext(), pay, new ApiCallback()
    {
        public void onSuccess(String content)
        {
            Log.d("U8SDK", "pay success");
            U8SDK.getInstance().onResult(10, "pay success");
        }

        public void onFailure(String content, int code)
        {
            Log.d("U8SDK", "pay failed.content:" + content);
            U8SDK.getInstance().onResult(11, content);
        }
    });
}

4悬浮


 @Override
    public void onPause() {
     // TODO Auto-generated method stub
     GameCenterSDK.getInstance().onPause();
    }
    @Override
    public void onResume() {
     // TODO Auto-generated method stub
     GameCenterSDK.getInstance().onResume(mContext);
    }

5上传信息:
{
    ReportUserGameInfoParam param = new ReportUserGameInfoParam(this.appID, data.getServerName(), data.getRoleName(), data.getRoleLevel());
    GameCenterSDK.getInstance().doReportUserGameInfoData(param, new ApiCallback()
    {
        public void onSuccess(String arg0)
        {
            Log.d("U8SDK", "sendExtraData success");
        }

        public void onFailure(String arg0, int arg1)
        {
            Log.d("U8SDK", "sendExtraData failed." + arg0);
        }
    });
}

你可能感兴趣的:(游戏sdk接入)