| | |
| | | |
| | | flavorDimensions "default" |
| | | productFlavors { |
| | | // 思璞SDK |
| | | // quickSDK |
| | | game_qk{ |
| | | dimension "default" |
| | | manifestPlaceholders.put("appId", "com.zyxhgame.mxd") |
| | | manifestPlaceholders.put("appId", "com.xfzc.yj.quick") |
| | | manifestPlaceholders.put("TrackAppID", "5ae23b6b905f98d9b8bd542debf35678") |
| | | manifestPlaceholders.put("TrackChannelID", "_default_") |
| | | manifestPlaceholders.put("JpushAppKey", "22186239fee975f883198cf4") |
| | |
| | | import android.support.v4.content.ContextCompat; |
| | | import android.support.v4.content.FileProvider; |
| | | import android.text.method.QwertyKeyListener; |
| | | import android.util.Log; |
| | | import android.widget.Toast; |
| | | |
| | | import com.quicksdk.QuickSDK; |
| | |
| | | public class H2EngineSDK |
| | | { |
| | | private static final String TAG = "H2EngineSDK"; |
| | | |
| | | private static boolean PushEnable = true; |
| | | private static String APP_ID = ""; |
| | | private static boolean PushEnable = false; |
| | | |
| | | public static void HandleUnityMessage(String json) |
| | | { |
| | |
| | | switch (_code) |
| | | { |
| | | case CodeU2A.Init: |
| | | APP_ID = _json.getString("appID"); |
| | | init(_activity); |
| | | break; |
| | | case CodeU2A.CopyOneAsset: |
| | |
| | | case CodeU2A.FreePlatformPay: |
| | | |
| | | JSONObject _extraData = new JSONObject(); |
| | | String _yjAppID = UniversalUtil.getMetaString(_activity, "yj_appid"); |
| | | _extraData.put("appid", _yjAppID); |
| | | String _appid = com.quicksdk.Extend.getInstance().getExtrasConfig("zfappid"); |
| | | if (_appid == "") |
| | | { |
| | | //没有打包的自定义参数则取配置表 |
| | | _appid = APP_ID; |
| | | } |
| | | _extraData.put("appid", _appid); |
| | | _extraData.put("cpinfo", _json.getString("cpInfo")); |
| | | _extraData.put("cporderid", _json.getString("orderId")); |
| | | try |
| | |
| | | GameRoleInfo roleInfo3 = new GameRoleInfo(); |
| | | roleInfo3.setServerID(_json.getString("sid")); |
| | | roleInfo3.setServerName(_json.getString("serverName")); |
| | | roleInfo3.setGameRoleName(_json.getString("roleName").trim().replace(" ", |
| | | "")); |
| | | roleInfo3.setGameRoleName(_json.getString("roleName").trim().replace(" ", "")); |
| | | roleInfo3.setGameRoleID(_json.getString("roleID")); |
| | | roleInfo3.setGameBalance(_json.getString("money")); |
| | | roleInfo3.setVipLevel(_json.getString( |
| | | "vipLevel")); //设置当前用户vip等级,必须为数字整型字符串,请勿传"vip1"等类似字符串 |
| | | roleInfo3.setVipLevel(_json.getString("vipLevel")); //设置当前用户vip等级,必须为数字整型字符串,请勿传"vip1"等类似字符串 |
| | | roleInfo3.setGameUserLevel(_json.getString("level"));//设置游戏角色等级 |
| | | roleInfo3.setPartyName(_json.getString("familyName").trim().replace(" ", |
| | | ""));//设置帮派名称 |
| | | roleInfo3.setRoleCreateTime( |
| | | _json.getString("createTime")); //UC,当乐与1881,TT渠道必传,值为10位数时间戳 |
| | | roleInfo3.setPartyName(_json.getString("familyName").trim().replace(" ", ""));//设置帮派名称 |
| | | roleInfo3.setRoleCreateTime(_json.getString("createTime")); //UC,当乐与1881,TT渠道必传,值为10位数时间戳 |
| | | |
| | | roleInfo3.setPartyId("1100"); //360渠道参数,设置帮派id,必须为整型字符串 |
| | | roleInfo3.setGameRolePower("38"); //360,TT语音渠道参数,设置角色战力,必须为整型字符串 |
| | |
| | | // .replace(" ", ""), |
| | | // _json.getString("vipLevel"), |
| | | // _json.getString("money")); |
| | | verifyRealName(_activity); |
| | | break; |
| | | case CodeU2A.RoleLevelUp: |
| | | GameRoleInfo roleInfo2 = new GameRoleInfo(); |
| | |
| | | return; |
| | | } |
| | | |
| | | PushEnable = activity.getPackageName().equals("com.xjaz.sp"); |
| | | //PushEnable = activity.getPackageName().equals("com.xjaz.sp"); |
| | | |
| | | new Thread(new Runnable() |
| | | { |
| | |
| | | |
| | | _msgStruct.clear(); |
| | | _msgStruct.put("code", CodeA2U.SdkInitComplete); |
| | | _msgStruct.put("channelPlatform", "yj"); |
| | | String _appid = UniversalUtil.getMetaString(activity, "yj_appid"); |
| | | _msgStruct.put("channelPlatform", "quick"); |
| | | //根据appid是否相同和后台配置 可调整混服和专服 |
| | | //打包工具可添加自定义参数 |
| | | String _appid = com.quicksdk.Extend.getInstance().getExtrasConfig("zfappid"); |
| | | if (_appid == "") |
| | | { |
| | | //没有打包的自定义参数则取配置表 |
| | | _appid = APP_ID; |
| | | } |
| | | _msgStruct.put("yj_appid", _appid); |
| | | _msgStruct.put("yj_spid", UniversalUtil.getMetaString(activity, "yj_spid")); |
| | | _msgStruct.put("yj_branch", UniversalUtil.getMetaInt(activity, "yj_branch")); |
| | | _msgStruct.put("banhao", activity.getResources().getString(R.string.banhao)); |
| | | _msgStruct.put("yj_spid", com.quicksdk.Extend.getInstance().getChannelType()); |
| | | UniversalUtil.sendMessageToUnity(_msgStruct); |
| | | |
| | | LogUtil.i(TAG, "初始化执行完毕"); |
| | |
| | | |
| | | public static void onCreate(Activity activity, Bundle savedInstanceState) |
| | | { |
| | | QuickSDK.getInstance().setIsLandScape(true); |
| | | Sdk.getInstance().onCreate(activity); |
| | | try { |
| | | // check权限 |
| | |
| | | Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 1); |
| | | } else { |
| | | QuickPlatformUtil.getInstance().onCreate(); |
| | | Sdk.getInstance().init(activity,"88049844578484520615487574815873", "82414864"); |
| | | Sdk.getInstance().init(activity,"96065423134516611008224414549989", "69623854"); |
| | | } |
| | | } catch (Exception e) { |
| | | QuickPlatformUtil.getInstance().onCreate(); |
| | | Sdk.getInstance().init(activity, "88049844578484520615487574815873", "82414864"); |
| | | Sdk.getInstance().init(activity, "96065423134516611008224414549989", "69623854"); |
| | | } |
| | | QuickSDK.getInstance().setIsLandScape(true); |
| | | } |
| | | |
| | | private static boolean m_IsFocus = true; |
| | |
| | | { |
| | | Sdk.getInstance().onDestroy(activity); |
| | | } |
| | | |
| | | private static void verifyRealName(final Activity activity) { |
| | | activity.runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 判断渠道是否支持实名认证功能 |
| | | if (com.quicksdk.Extend.getInstance().isFunctionSupported(com.quicksdk.FuncType.REAL_NAME_REGISTER)) { |
| | | com.quicksdk.Extend.getInstance().callFunctionWithParamsCallBack(activity, com.quicksdk.FuncType.REAL_NAME_REGISTER, new com.quicksdk.BaseCallBack() { |
| | | @Override |
| | | public void onSuccess(Object... arg0) { |
| | | if (arg0 != null && arg0.length > 0) { |
| | | JSONObject jsonObject = (JSONObject) arg0[0]; |
| | | Log.d("json", "==========" + jsonObject.toString()); |
| | | try { |
| | | // 用户id |
| | | String uid = jsonObject.getString("uid"); |
| | | // 年龄, 如果渠道没返回默认为-1 |
| | | int age = jsonObject.getInt("age"); |
| | | // 是否已实名 true表示已实名 |
| | | // false表示未实名,如果渠道没返回默认为false |
| | | boolean realName = jsonObject.getBoolean("realName"); |
| | | // oppo实名认证失败之后是否可以继续游戏 true表示可以 |
| | | // false表示不可以,如果渠道没返回默认为true |
| | | boolean resumeGame = jsonObject.getBoolean("resumeGame"); |
| | | // 预留字段,如果渠道没返回默认为""的字符串 |
| | | String other = jsonObject.getString("other"); |
| | | // 游戏根据返回信息做对应的逻辑处理 |
| | | |
| | | } catch (JSONException e) { |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailed(Object... arg0) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | |
| | | USER = userInfo; |
| | | |
| | | //根据回调获取用户信息 |
| | | String timestamp = USER.getToken(); |
| | | String token = USER.getToken(); |
| | | String userId = USER.getUID(); |
| | | String userName = USER.getUserName(); |
| | | try |
| | | { |
| | | JSONObject _info = new JSONObject(); |
| | | _info.put("account", userName); |
| | | _info.put("account", userId); |
| | | _info.put("token", token); |
| | | _info.put("timeStamp", timestamp); |
| | | _info.put("account_id", userId); |
| | | _info.put("userName", userName); |
| | | m_Message.put("code", CodeA2U.FreePlatformLoginOk); |
| | | m_Message.put("info", _info); |
| | | UniversalUtil.sendMessageToUnity(m_Message); |
| | |
| | | USER = userInfo; |
| | | |
| | | //根据回调获取用户信息 |
| | | String timestamp = USER.getToken(); |
| | | String token = USER.getToken(); |
| | | String userId = USER.getUID(); |
| | | String userName = USER.getUserName(); |
| | | try |
| | | { |
| | | JSONObject _info = new JSONObject(); |
| | | _info.put("account", userName); |
| | | _info.put("userName", userName); |
| | | _info.put("token", token); |
| | | _info.put("timeStamp", timestamp); |
| | | _info.put("account_id", userId); |
| | | _info.put("account", userId); |
| | | m_Message.put("code", CodeA2U.FreePlatformSwitchAccountOk); |
| | | m_Message.put("info", _info); |
| | | UniversalUtil.sendMessageToUnity(m_Message); |
| | |
| | | public void onSuccess() { |
| | | //退出成功,游戏在此做自身的退出逻辑处理 |
| | | m_Message.clear(); |
| | | m_Message.put("code", CodeA2U.FreePlatformExit); |
| | | m_Message.put("code", CodeA2U.ExitGame); |
| | | UniversalUtil.sendMessageToUnity(m_Message); |
| | | payProcessing = false; |
| | | } |
| | |
| | | android:name="com.samsung.android.keepalive.density" |
| | | android:value="true" /> |
| | | |
| | | <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true"></meta-data> |
| | | |
| | | </activity> |
| | | </application> |
| | | |
| | |
| | | public static final int FreePlatformPayFail = 19; |
| | | public static final int FreePlatformPayCancel = 20; |
| | | public static final int FreePlatformRegisterOk = 21; |
| | | public static final int FreePlatformExit = 22; |
| | | } |
| | |
| | | import android.provider.Settings; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.v4.app.ActivityCompat; |
| | | import android.support.v4.content.ContextCompat; |
| | | import android.support.v4.content.PermissionChecker; |
| | | import android.util.Log; |
| | | import android.view.KeyEvent; |
| | |
| | | View unityView = mUnityPlayer.getView(); |
| | | _frameLayout.addView(unityView); |
| | | |
| | | H2EngineSDK.onCreate(this, savedInstanceState); |
| | | //H2EngineSDK.onCreate(this, savedInstanceState); |
| | | |
| | | Sdk.getInstance().onCreate(this); |
| | | try { |
| | | // check权限 |
| | | if ((ContextCompat.checkSelfPermission(this, |
| | | Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) |
| | | || (ContextCompat.checkSelfPermission(this, |
| | | Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) { |
| | | // 没有 , 申请权限 权限数组 |
| | | ActivityCompat.requestPermissions(this, new String[] { |
| | | Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 1); |
| | | } else { |
| | | QuickPlatformUtil.getInstance().onCreate(); |
| | | Sdk.getInstance().init(this,"96065423134516611008224414549989", "69623854"); |
| | | } |
| | | } catch (Exception e) { |
| | | QuickPlatformUtil.getInstance().onCreate(); |
| | | Sdk.getInstance().init(this, "96065423134516611008224414549989", "69623854"); |
| | | } |
| | | QuickSDK.getInstance().setIsLandScape(true); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // 申请成功 |
| | | QuickPlatformUtil.getInstance().onCreate(); |
| | | if (!QuickPlatformUtil.getInstance().isInited) { |
| | | Sdk.getInstance().init(this, "88049844578484520615487574815873", "82414864"); |
| | | Sdk.getInstance().init(this, "96065423134516611008224414549989", "69623854"); |
| | | } |
| | | } else { |
| | | // 失败 这里逻辑以游戏为准 这里只是模拟申请失败 退出游戏 cp方可改为继续申请 或者其他逻辑 |
| | |
| | | intent.setData(uri); |
| | | startActivityForResult(intent, REQUEST_RECORD_PERMISSION_SETTING); |
| | | QuickPlatformUtil.getInstance().onCreate(); |
| | | Sdk.getInstance().init(UnityPlayer.currentActivity, "88049844578484520615487574815873", "82414864"); |
| | | Sdk.getInstance().init(UnityPlayer.currentActivity, "96065423134516611008224414549989", "69623854"); |
| | | } |
| | | }); |
| | | normalDialog.setNegativeButton("关闭", new DialogInterface.OnClickListener() { |
| | |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | Toast.makeText(UnityPlayer.currentActivity, "权限被拒绝", Toast.LENGTH_SHORT).show(); |
| | | QuickPlatformUtil.getInstance().onCreate(); |
| | | Sdk.getInstance().init(UnityPlayer.currentActivity, "88049844578484520615487574815873", "82414864"); |
| | | Sdk.getInstance().init(UnityPlayer.currentActivity, "96065423134516611008224414549989", "69623854"); |
| | | } |
| | | }); |
| | | // 显示 |
| | |
| | | super.onResume(); |
| | | |
| | | // 检测本地存储权限是否有, 没有的话要提示用户 |
| | | if (PermissionChecker.checkPermission(this, |
| | | Manifest.permission.WRITE_EXTERNAL_STORAGE, |
| | | Process.myPid(), Process.myUid(), |
| | | getPackageName()) != PackageManager.PERMISSION_GRANTED |
| | | || PermissionChecker.checkPermission(this, |
| | | Manifest.permission.READ_EXTERNAL_STORAGE, |
| | | Process.myPid(), Process.myUid(), |
| | | getPackageName()) != PackageManager.PERMISSION_GRANTED) |
| | | { |
| | | new AlertDialog.Builder(this) |
| | | .setMessage("应用没有存储读取权限,点击确定至设置中开启,否则无法继续游戏.") |
| | | .setCancelable(false) |
| | | .setPositiveButton("确定", |
| | | new DialogInterface.OnClickListener() |
| | | { |
| | | @Override |
| | | public void onClick(DialogInterface dialogInterface, |
| | | int i) |
| | | { |
| | | UniversalUtil.hasGoToSetting = true; |
| | | Intent intent = new Intent( |
| | | Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | Uri uri = Uri.fromParts("package", |
| | | getPackageName(), |
| | | null); |
| | | intent.setData(uri); |
| | | startActivity(intent); |
| | | } |
| | | }) |
| | | .setNegativeButton("拒绝", |
| | | new DialogInterface.OnClickListener() |
| | | { |
| | | @Override |
| | | public void onClick(DialogInterface dialogInterface, |
| | | int i) |
| | | { |
| | | finish(); |
| | | } |
| | | }) |
| | | .show(); |
| | | } |
| | | // if (PermissionChecker.checkPermission(this, |
| | | // Manifest.permission.WRITE_EXTERNAL_STORAGE, |
| | | // Process.myPid(), Process.myUid(), |
| | | // getPackageName()) != PackageManager.PERMISSION_GRANTED |
| | | // || PermissionChecker.checkPermission(this, |
| | | // Manifest.permission.READ_EXTERNAL_STORAGE, |
| | | // Process.myPid(), Process.myUid(), |
| | | // getPackageName()) != PackageManager.PERMISSION_GRANTED) |
| | | // { |
| | | // new AlertDialog.Builder(this) |
| | | // .setMessage("应用没有存储读取权限,点击确定至设置中开启,否则无法继续游戏.") |
| | | // .setCancelable(false) |
| | | // .setPositiveButton("确定", |
| | | // new DialogInterface.OnClickListener() |
| | | // { |
| | | // @Override |
| | | // public void onClick(DialogInterface dialogInterface, |
| | | // int i) |
| | | // { |
| | | // UniversalUtil.hasGoToSetting = true; |
| | | // Intent intent = new Intent( |
| | | // Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | // Uri uri = Uri.fromParts("package", |
| | | // getPackageName(), |
| | | // null); |
| | | // intent.setData(uri); |
| | | // startActivity(intent); |
| | | // } |
| | | // }) |
| | | // .setNegativeButton("拒绝", |
| | | // new DialogInterface.OnClickListener() |
| | | // { |
| | | // @Override |
| | | // public void onClick(DialogInterface dialogInterface, |
| | | // int i) |
| | | // { |
| | | // finish(); |
| | | // } |
| | | // }) |
| | | // .show(); |
| | | // } |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | return super.onKeyDown(i, keyEvent); |
| | | } |
| | | |
| | | |
| | | } |