| | |
| | | } |
| | | |
| | | public void onRequestPermissionsResult(Activity activity, int requestCode, int[] grantResults, String[] permissions) { |
| | | PlatformDiff.I.OnRequestPermissionsResult(requestCode, grantResults, permissions); |
| | | if (requestCode != RequestCode.QUICK) return; |
| | | |
| | | |
| | | if (hasPermissions(activity)) { |
| | | LogUtil.i("SdkManager", "onRequestPermissionsResult 申请成功"); |
| | | //if (hasPermissions(activity)) |
| | | { |
| | | LogUtil.i("SdkManager", "onRequestPermissionsResult 不管是否申请成功都初始化"); |
| | | //申请成功 |
| | | QuickSdkMgr.I.register(PlatformDiff.I.platformProductCode(), PlatformDiff.I.platformProductKey()); |
| | | QuickSdkMgr.I.init(activity); |
| | | return; |
| | | } |
| | | final AlertDialog.Builder normalDialog = new AlertDialog.Builder(activity); |
| | | normalDialog.setTitle("权限设置"); |
| | | normalDialog.setMessage("游戏需要部分权限才能正常运行,请前往设置中打开存储权限"); |
| | | normalDialog.setPositiveButton("前往设置", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | Uri uri = Uri.fromParts("package", activity.getPackageName(), null); |
| | | intent.setData(uri); |
| | | activity.startActivityForResult(intent, REQUEST_RECORD_PERMISSION_SETTING); |
| | | dialog.dismiss(); |
| | | } |
| | | }); |
| | | normalDialog.setNegativeButton("退出", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | GameAppProxy.appExit(); |
| | | } |
| | | }); |
| | | // 显示 |
| | | normalDialog.show(); |
| | | // final AlertDialog.Builder normalDialog = new AlertDialog.Builder(activity); |
| | | // normalDialog.setTitle("权限设置"); |
| | | // normalDialog.setMessage("游戏需要部分权限才能正常运行,请前往设置中打开存储权限"); |
| | | // normalDialog.setPositiveButton("前往设置", new DialogInterface.OnClickListener() { |
| | | // @Override |
| | | // public void onClick(DialogInterface dialog, int which) { |
| | | // Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | // Uri uri = Uri.fromParts("package", activity.getPackageName(), null); |
| | | // intent.setData(uri); |
| | | // activity.startActivityForResult(intent, REQUEST_RECORD_PERMISSION_SETTING); |
| | | // dialog.dismiss(); |
| | | // } |
| | | // }); |
| | | // normalDialog.setNegativeButton("退出", new DialogInterface.OnClickListener() { |
| | | // @Override |
| | | // public void onClick(DialogInterface dialog, int which) { |
| | | // GameAppProxy.appExit(); |
| | | // } |
| | | // }); |
| | | // // 显示 |
| | | // normalDialog.show(); |
| | | } |
| | | |
| | | public void onActivityResult(Activity activity, int requestCode) { |
| | | if (requestCode == REQUEST_RECORD_PERMISSION_SETTING) |
| | | { |
| | | LogUtil.i("SdkManager", "onActivityResult"); |
| | | LogUtil.i("unity-sdk", "onActivityResult"); |
| | | requestPermissions(activity); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | public void login() { |
| | | PlatformDiff.I.Login(); |
| | | switch (sdkInitState) { |
| | | case FAILED: |
| | | case UNKNOWN: { |
| | | if (GameActivityProxy.I.activity == null) |
| | | return; |
| | | if (hasPermissions(GameActivityProxy.I.activity)) { |
| | | //init(BtGameMain.I.activity); |
| | | Toast.makeText(GameAppProxy.app, "异常请重启游戏", Toast.LENGTH_LONG).show(); |
| | | } |
| | | break; |
| | | } |
| | | case SUCCEED: { |
| | | //User.getInstance().login(GameActivityProxy.I.activity); |
| | | GameActivityProxy.I.activity.runOnUiThread(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | User.getInstance().login(GameActivityProxy.I.activity); |
| | | } |
| | | }); |
| | | break; |
| | | } |
| | | case LOADING: { |
| | | Toast.makeText(GameAppProxy.app, "正在初始化中,请稍等!", Toast.LENGTH_LONG).show(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void loginOut() { |
| | |
| | | sdkInitState = SdkInitState.SUCCEED; |
| | | LogUtil.debug("SdkManager", "初始化成功"); |
| | | UnityMsgHandler.sendMessageToUnity(CodeA2U.PlatformInitOk); |
| | | PlatformDiff.I.RegisterEvent("youxitu"); |
| | | } |
| | | @Override |
| | | public void onFailed(String message, String trace) { |
| | |
| | | e.printStackTrace(); |
| | | LogUtil.e("SdkManager 登录成功", e); |
| | | } |
| | | PlatformDiff.I.LoginSuccess(); |
| | | verifyRealName(); |
| | | } |
| | | |