private NgamesSdk ngamesSdk;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
// 初始化
ngamesSdk = NgamesSdk.getInstance(this, this, Const.LANG_EN);
}
public static NgamesSdk getInstance(Context context, Activity activity, String lang)
/**
* 设置支持的登录方式
* @param isSupportGoogle 是否支持Google登录
* @param isSupportFacebook 是否支持acebook登录
* @param isSupportGamesamba 是否支持Gamesamba登录
*/
public void setLoginSupport(boolean isSupportGoogle, boolean isSupportFacebook, boolean isSupportGamesamba)
ngamesSdk.setLoginSupport(true,true,false);
/**
* 设置悬浮框支持的功能
* @param isOpenShare 是否打开分享
* @param isOpenFeedback 是否打开客服功能
* @param isOpenDiscord 是否打开Discord
*/
public void setPopSupportFunction(boolean isOpenShare, boolean isOpenFeedback, boolean isOpenDiscord)
//只开启客服功能
ngamesSdk.setPopSupportFunction(false, true, false);
...
@Override
protected void onResume() {
super.onResume();
...
if (ngamesSdk != null) {
ngamesSdk.onResume();
}
}
...
@Override
protected void onDestroy() {
super.onDestroy();
...
if (ngamesSdk != null) {
ngamesSdk.onDestroy();
}
}
在主Activity#onConfigurationChanged中
...
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
...
if (ngamesSdk != null) {
ngamesSdk.onConfigurationChanged();
}
}
在主Activity#onActivityResult中
...
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
...
if (ngamesSdk != null && ngamesSdk.handleActivityResult(requestCode, resultCode, data)) {
return;
}
if (requestCode == Const.THIRD_LOGIN_REQUEST_CODE) {
switch (resultCode) {
case Const.INTENT_RESULT_OK:
AccountResult loginUser = (AccountResult) data.getSerializableExtra(Const.LOGIN_USER);
//获取登录的用户信息
break;
case Const.INTENT_RESULT_CANCELED:
//登录取消
break;
case Const.INTENT_RESULT_ERROR:
//登录失败
break;
}
return;
}
...
super.onActivityResult(requestCode, resultCode, data);
}
/**
* 设置调试模式
* @param isDebug
*/
public void setDebug(boolean isDebug)
ngamesSdk.setDebug(true);//设置Debug模式
/**
* 设置支持切换帐号
* @param isSupport
*/
public void setSupportSwitchAccount(boolean isSupport)
ngamesSdk.setSupportSwitchAccount(true);//设置不支持帐号切换