xuguohong

重新添加公共sdk接入资料

Showing 75 changed files with 2581 additions and 0 deletions
1 +/demo/Demo_PoolSdk/gen
2 +/demo/Demo_PoolSdk/bin
...\ No newline at end of file ...\ No newline at end of file
1 +- 2019-09-02
2 + - 修改PoolSdk_V2 assets/sdk assets/sdk.zip
3 +- 2019-11-15
4 + - libs修改PoolSdk_V2,YouYuSDK_xxx.jar为191016版本,添加miit_mdid_1.0.10.aar
5 + - assets中添加supplierconfig.json,poolsdk.xml添加styleName字段
6 + - 添加事件上报接口(具体查看接入文档)
7 +- 2019-11-28
8 + - 更新为YouYuSDK_1128.jar版本
9 +- 2019-12-04
10 + - 更新更新PoolSdk_V2包名,将YouYuSDK_xxx.jar替换为AppSdk_xxx.jar,替换assets下的sdk和sdk.zip
11 +- 2019-12-19
12 + - 更新PoolSdk_V2,删除assets中sdk/sdk.zip/sdkconfig.ini 删除AppSdk_xxx.jar,android-support-v4.jar
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" ?>
2 +<config>
3 + <sdkconfig channelparameter1="" channelparameter2="" custom="{}" gamechannelid="" gamesimplename="ces" logceportcrl="https://public.sdk.guangkatf.com/sdk/statistic" logincheckurl="https://public.sdk.guangkatf.com/logincheck/check" paycheckurl="https://public.sdk.guangkatf.com/paycheck/confirm" payorderurl="https://public.sdk.guangkatf.com/paycheck/create" sdksimplename="poolsdk" sdkversioncode="V1_0" usertype="597"/>
4 +</config>
1 +{
2 + "supplier":{
3 + "vivo":{
4 + "appid":"100215079"
5 + },
6 + "xiaomi":{
7 +
8 + },
9 + "huawei":{
10 +
11 + },
12 + "oppo":{
13 +
14 + }
15 + }
16 +
17 +}
1 +*.iml
2 +.gradle
3 +/local.properties
4 +/.idea/caches
5 +/.idea/libraries
6 +/.idea/modules.xml
7 +/.idea/workspace.xml
8 +/.idea/navEditor.xml
9 +/.idea/assetWizardSettings.xml
10 +.DS_Store
11 +/build
12 +/captures
13 +.externalNativeBuild
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="Encoding" addBOMForNewFiles="with NO BOM" />
4 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="GradleSettings">
4 + <option name="linkedExternalProjectsSettings">
5 + <GradleProjectSettings>
6 + <option name="distributionType" value="DEFAULT_WRAPPED" />
7 + <option name="externalProjectPath" value="$PROJECT_DIR$" />
8 + <option name="modules">
9 + <set>
10 + <option value="$PROJECT_DIR$" />
11 + <option value="$PROJECT_DIR$/app" />
12 + </set>
13 + </option>
14 + <option name="resolveModulePerSourceSet" value="false" />
15 + </GradleProjectSettings>
16 + </option>
17 + </component>
18 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
4 + <output url="file://$PROJECT_DIR$/build/classes" />
5 + </component>
6 + <component name="ProjectType">
7 + <option name="id" value="Android" />
8 + </component>
9 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="RunConfigurationProducerService">
4 + <option name="ignoredProducers">
5 + <set>
6 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
7 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
8 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
9 + </set>
10 + </option>
11 + </component>
12 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="VcsDirectoryMappings">
4 + <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5 + </component>
6 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +apply plugin: 'com.android.application'
2 +
3 +android {
4 + compileSdkVersion 29
5 + buildToolsVersion '29.0.2'
6 + defaultConfig {
7 + applicationId "com.ssjh.demo"
8 + targetSdkVersion 28
9 + versionCode 2
10 + versionName "1.0"
11 + }
12 + buildTypes {
13 + release {
14 + minifyEnabled false
15 + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
16 + }
17 + }
18 +}
19 +
20 +dependencies {
21 + implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
22 +}
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
1 +# Add project specific ProGuard rules here.
2 +# You can control the set of applied configuration files using the
3 +# proguardFiles setting in build.gradle.
4 +#
5 +# For more details, see
6 +# http://developer.android.com/guide/developing/tools/proguard.html
7 +
8 +# If your project uses WebView with JS, uncomment the following
9 +# and specify the fully qualified class name to the JavaScript interface
10 +# class:
11 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 +# public *;
13 +#}
14 +
15 +# Uncomment this to preserve the line number information for
16 +# debugging stack traces.
17 +#-keepattributes SourceFile,LineNumberTable
18 +
19 +# If you keep the line number information, uncomment this to
20 +# hide the original source file name.
21 +#-renamesourcefileattribute SourceFile
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 + package="com.youai.demo.shenshou">
4 +
5 + <!-- SDK start -->
6 + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
7 + <uses-permission android:name="android.permission.INTERNET" />
8 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
9 + <uses-permission android:name="android.permission.READ_PHONE_STATE" />
10 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
11 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
12 + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
13 + <uses-permission android:name="android.permission.GET_TASKS" />
14 + <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
15 + <uses-permission android:name="android.permission.RECORD_AUDIO" />
16 + <!-- SDK end -->
17 +
18 + <application
19 + android:name="com.gzpublic.app.sdk.application.PoolSDKApplication"
20 + android:allowBackup="true"
21 + android:icon="@drawable/public_sdk_self_ic_launcher"
22 + android:label="@string/app_name" >
23 + <activity
24 + android:name="com.youai.foolsdk.demo.AppActivity"
25 + android:configChanges="keyboardHidden|orientation|screenSize"
26 + android:label="@string/app_name"
27 + android:screenOrientation="portrait"
28 + android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
29 + <intent-filter>
30 + <action android:name="android.intent.action.MAIN" />
31 +
32 + <category android:name="android.intent.category.LAUNCHER" />
33 + </intent-filter>
34 + </activity>
35 + <!-- SDK start -->
36 + <activity
37 + android:name="com.appsdk.sdk.YouaiSDK"
38 + android:label="youai_sdk"
39 + android:launchMode="singleTask"
40 + android:theme="@android:style/Theme.Dialog" />
41 +
42 + <service
43 + android:name="com.appsdk.sdk.YouaiService"
44 + android:enabled="true" >
45 + <intent-filter>
46 + <action android:name="com.youai.sdk.YouaiService" />
47 + </intent-filter>
48 + </service>
49 +
50 + <receiver android:name="com.appsdk.sdk.Receiver" >
51 + <intent-filter>
52 + <action android:name="android.intent.action.BOOT_COMPLETED" />
53 +
54 + <category android:name="android.intent.category.LAUNCHER" />
55 + </intent-filter>
56 + </receiver>
57 +
58 + <activity
59 + android:name="com.alipay.sdk.app.H5PayActivity"
60 + android:configChanges="keyboardHidden|navigation|orientation"
61 + android:exported="false"
62 + android:screenOrientation="behind" />
63 + <activity
64 + android:name="com.alipay.sdk.auth.AuthActivity"
65 + android:configChanges="keyboardHidden|navigation|orientation"
66 + android:exported="false"
67 + android:screenOrientation="behind" />
68 + <!-- SDK end -->
69 + </application>
70 +
71 +</manifest>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" ?>
2 +<config>
3 + <sdkconfig channelparameter1="" channelparameter2="" custom="{}" gamechannelid="" gamesimplename="ces" logceportcrl="https://public.sdk.guangkatf.com/sdk/statistic" logincheckurl="https://public.sdk.guangkatf.com/logincheck/check" paycheckurl="https://public.sdk.guangkatf.com/paycheck/confirm" payorderurl="https://public.sdk.guangkatf.com/paycheck/create" sdksimplename="poolsdk" sdkversioncode="V1_0" usertype="597"/>
4 +</config>
1 +{
2 + "supplier":{
3 + "vivo":{
4 + "appid":"100215079"
5 + },
6 + "xiaomi":{
7 +
8 + },
9 + "huawei":{
10 +
11 + },
12 + "oppo":{
13 +
14 + }
15 + }
16 +
17 +}
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 + package="com.youai.poolsdk.demo"
4 + android:versionCode="1"
5 + android:versionName="1.0" >
6 +
7 + <uses-sdk
8 + android:minSdkVersion="8"
9 + android:targetSdkVersion="19" />
10 +
11 + <!-- SDK start -->
12 + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
13 + <uses-permission android:name="android.permission.INTERNET" />
14 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
15 + <uses-permission android:name="android.permission.READ_PHONE_STATE" />
16 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
17 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
18 + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
19 + <uses-permission android:name="android.permission.READ_LOGS" />
20 + <uses-permission android:name="android.permission.GET_TASKS" />
21 + <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
22 + <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
23 + <uses-permission android:name="android.permission.RECORD_AUDIO" />
24 + <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
25 + <uses-permission android:name="org.simalliance.openmobileapi.SMARTCARD" />
26 + <uses-permission android:name="android.permission.NFC" />
27 + <uses-feature android:name="android.hardware.nfc.hce" />
28 + <!-- SDK end -->
29 +
30 + <application
31 + android:name="com.gzyouai.publicsdk.application.PoolSDKApplication"
32 + android:allowBackup="true"
33 + android:icon="@drawable/public_sdk_self_ic_launcher"
34 + android:label="@string/app_name" >
35 + <activity
36 + android:name="com.youai.foolsdk.demo.AppActivity"
37 + android:configChanges="keyboardHidden|orientation|screenSize"
38 + android:label="@string/app_name"
39 + android:screenOrientation="landscape"
40 + android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
41 + <intent-filter>
42 + <action android:name="android.intent.action.MAIN" />
43 +
44 + <category android:name="android.intent.category.LAUNCHER" />
45 + </intent-filter>
46 + </activity>
47 + <!-- SDK start -->
48 + <receiver
49 + android:name="com.gzyouai.fengniao.sdk.framework.AppInstallReceiver"
50 + android:label="@string/app_name" >
51 + <intent-filter>
52 + <action android:name="android.intent.action.PACKAGE_ADDED" />
53 + <action android:name="android.intent.action.PACKAGE_REPLACED" />
54 + <action android:name="android.intent.action.PACKAGE_REMOVED" />
55 +
56 + <data android:scheme="package" />
57 + </intent-filter>
58 + </receiver>
59 +
60 + <activity
61 + android:name="com.youai.sdk.YouaiSDK"
62 + android:label="youai_sdk"
63 + android:launchMode="singleTask"
64 + android:theme="@android:style/Theme.Dialog" />
65 +
66 + <service
67 + android:name="com.youai.sdk.YouaiService"
68 + android:enabled="true" >
69 + <intent-filter>
70 + <action android:name="com.youai.sdk.YouaiService" />
71 + </intent-filter>
72 + </service>
73 + <service
74 + android:name="com.youai.sdk.FloatViewService"
75 + android:enabled="true"
76 + android:exported="true" >
77 + <intent-filter>
78 + <action android:name="com.youai.sdk.FloatViewService" />
79 + </intent-filter>
80 + </service>
81 +
82 + <receiver android:name="com.youai.sdk.Receiver" >
83 + <intent-filter>
84 + <action android:name="android.intent.action.BOOT_COMPLETED" />
85 +
86 + <category android:name="android.intent.category.LAUNCHER" />
87 + </intent-filter>
88 + </receiver>
89 +
90 + <activity
91 + android:name="com.alipay.sdk.app.H5PayActivity"
92 + android:configChanges="keyboardHidden|navigation|orientation"
93 + android:exported="false"
94 + android:screenOrientation="behind" />
95 + <activity
96 + android:name="com.alipay.sdk.auth.AuthActivity"
97 + android:configChanges="keyboardHidden|navigation|orientation"
98 + android:exported="false"
99 + android:screenOrientation="behind" />
100 + <activity
101 + android:name=".wxapi.WXPayEntryActivity"
102 + android:exported="true"
103 + android:launchMode="singleTop" />
104 + <activity
105 + android:name=".wxapi.WXEntryActivity"
106 + android:exported="true"
107 + android:launchMode="singleTop" />
108 + <!-- SDK end -->
109 + </application>
110 +
111 +</manifest>
...\ No newline at end of file ...\ No newline at end of file
No preview for this file type
No preview for this file type
1 +# cache for current jar dependency. DO NOT EDIT.
2 +# format is <lastModified> <length> <SHA-1> <path>
3 +# Encoding is UTF-8
No preview for this file type
1 +package com.youai.foolsdk.demo;
2 +
3 +import android.app.Activity;
4 +import android.app.AlertDialog;
5 +import android.content.DialogInterface;
6 +import android.content.Intent;
7 +import android.content.res.Configuration;
8 +import android.os.Bundle;
9 +import android.os.Handler;
10 +import android.view.KeyEvent;
11 +import android.view.View;
12 +import android.view.View.OnClickListener;
13 +import android.view.WindowManager.LayoutParams;
14 +import android.widget.Button;
15 +import android.widget.TextView;
16 +
17 +import com.gzpublic.app.sdk.framework.PoolEventParameterName;
18 +import com.gzpublic.app.sdk.framework.PoolEventType;
19 +import com.gzpublic.app.sdk.framework.PoolExitDialogListener;
20 +import com.gzpublic.app.sdk.framework.PoolExitListener;
21 +import com.gzpublic.app.sdk.framework.PoolExpansionListener;
22 +import com.gzpublic.app.sdk.framework.PoolLoginInfo;
23 +import com.gzpublic.app.sdk.framework.PoolLoginListener;
24 +import com.gzpublic.app.sdk.framework.PoolLogoutListener;
25 +import com.gzpublic.app.sdk.framework.PoolPayInfo;
26 +import com.gzpublic.app.sdk.framework.PoolPayListener;
27 +import com.gzpublic.app.sdk.framework.PoolPayOrderConfirmHandler;
28 +import com.gzpublic.app.sdk.framework.PoolReport;
29 +import com.gzpublic.app.sdk.framework.PoolRoleInfo;
30 +import com.gzpublic.app.sdk.framework.PoolRoleListener;
31 +import com.gzpublic.app.sdk.framework.PoolSDKCallBackListener;
32 +import com.gzpublic.app.sdk.framework.PoolSDKCode;
33 +import com.gzpublic.app.sdk.framework.PoolSdkConfig;
34 +import com.gzpublic.app.sdk.framework.PoolSdkHelper;
35 +import com.gzpublic.app.sdk.framework.PoolSdkLog;
36 +import org.json.JSONArray;
37 +import org.json.JSONException;
38 +import org.json.JSONObject;
39 +
40 +import java.util.HashMap;
41 +import java.util.Map;
42 +
43 +public class AppActivity extends Activity implements OnClickListener {
44 + //新的view
45 + private Button btLogin;
46 + private Button btEnterGame;
47 + private Button btPay;
48 + private Button btLogout;
49 + private Button btSubRoleInfo;
50 + private Button btOpenChannel;
51 + private Button btSwitchAcc;
52 + private Button btOpenBbs;
53 +
54 + //提示LOG
55 + private TextView txMsg,txSdkMsg;
56 + private Activity mContext;
57 + private PoolPayListener mPoolPayListener = new PoolPayListener() {
58 +
59 + @Override
60 + public void onPaySuccess(String paramCustom) {//支付回调以服务端通知为准
61 + // TODO Auto-generated method stub
62 + //[{"orderId":"20180116114151740535D825","state":0,"productId":"1","productName":"金币","amout":0}]
63 + if(paramCustom == null || paramCustom.length() <= 0)
64 + {
65 + PoolSdkLog.logError("paysuccess data error :" + paramCustom);
66 + return;
67 + }
68 + try {
69 + PoolSdkLog.logInfo("paySuccess:" + paramCustom);
70 + JSONArray jsonArray = new JSONArray(paramCustom);
71 + StringBuilder orderIds = new StringBuilder();
72 + int length = jsonArray.length();
73 + for (int i = 0; i < length; i++) {
74 + JSONObject jb = jsonArray.getJSONObject(i);
75 + String orderId = jb.getString("orderId");
76 + orderIds.append(orderId);
77 + if(i != length -1) {//最后一项不加分割符
78 + orderIds.append(",");
79 + }
80 + }
81 + PoolSdkHelper.paymentSuccess(AppActivity.this, orderIds.toString());
82 + } catch (JSONException e) {
83 + // TODO Auto-generated catch block
84 + e.printStackTrace();
85 + }
86 + upTx("支付成功回调:" + paramCustom);
87 + }
88 +
89 + @Override
90 + public void onPayFailed(String paramCustom, String errorMsg) {
91 + // TODO Auto-generated method stub
92 + System.out.println("支付失败回调:" + paramCustom + "; errorMsg:"
93 + + errorMsg);
94 + upTx("支付失败回调:" + paramCustom + "; errorMsg:"
95 + + errorMsg);
96 + }
97 + };
98 +
99 + @Override
100 + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
101 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
102 + PoolSdkHelper.onRequestPermissionsResult(requestCode, permissions, grantResults);
103 + }
104 +
105 + @Override
106 + protected void onCreate(Bundle savedInstanceState) {
107 + super.onCreate(savedInstanceState);
108 + int layoutId = getResources().getIdentifier(
109 + "public_sdk_self_test", "layout", getPackageName());
110 + setContentView(layoutId);
111 + mContext = this;
112 + initView();
113 + PoolSdkLog.setIsShowLog(true);
114 + PoolSdkHelper.init(this, new PoolSDKCallBackListener() {
115 + @Override
116 + public void poolSdkCallBack(int code, String msg) {
117 + PoolSdkLog.logInfo("poolSdkCallBack:code:" + code + ",msg:" + msg);
118 + upTx("poolSdkCallBack:code:" + code + ",msg:" + msg);
119 + switch (code) {
120 + case PoolSDKCode.POOLSDK_INIT_SUCCESS:// 初始化成功
121 + PoolSdkLog.logInfo("游戏中收到初始化成功回调");
122 + new Handler().postDelayed(new Runnable() {
123 +
124 + @Override
125 + public void run() {
126 + login();
127 + }
128 + }, 1000);
129 + break;
130 + case PoolSDKCode.POOLSDK_INIT_FAIL:
131 + break;
132 + default:
133 + break;
134 + }
135 + }
136 + }, savedInstanceState);// init(this);// this为游戏的activity对象
137 +
138 + PoolSdkHelper.setPayListener(mPoolPayListener );
139 +
140 +
141 + PoolSdkHelper.setLogoutCallback(new PoolLogoutListener() {
142 + @Override
143 + public void onLogoutSuccess() {
144 + // TODO: 此处处理SDK登出的逻辑
145 + PoolSdkLog.logInfo("游戏中收到logoutSuccess回调");
146 + login();
147 + }
148 + });
149 +
150 +
151 + txSdkMsg.setText("sdksimplename:"+ PoolSdkConfig.getConfigByKey("sdksimplename")
152 + +"\nsdkversioncode:"+PoolSdkConfig.getConfigByKey("sdkversioncode")
153 + +"\ngamesimplename:"+PoolSdkConfig.getConfigByKey("gamesimplename")
154 + +"\nlogincheckurl:"+PoolSdkConfig.getConfigByKey("logincheckurl")
155 + );
156 + }
157 +
158 + @Override
159 + public void onStart() {
160 + super.onStart();
161 + PoolSdkHelper.onStart();
162 + }
163 +
164 + @Override
165 + public void onStop() {
166 + super.onStop();
167 + PoolSdkHelper.onStop();
168 + }
169 +
170 + @Override
171 + public void onDestroy() {
172 + super.onDestroy();
173 + PoolSdkHelper.onDestroy();
174 + }
175 +
176 + @Override
177 + public void onResume() {
178 + super.onResume();
179 + PoolSdkHelper.onResume();
180 + }
181 +
182 + @Override
183 + public void onPause() {
184 + super.onPause();
185 + PoolSdkHelper.onPause();
186 +
187 + }
188 +
189 + @Override
190 + public void onRestart() {
191 + super.onRestart();
192 + PoolSdkHelper.onRestart();
193 + }
194 +
195 + @Override
196 + public void onNewIntent(Intent intent) {
197 + super.onNewIntent(intent);
198 + PoolSdkHelper.onNewIntent(intent);
199 + }
200 +
201 + @Override
202 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
203 + PoolSdkHelper.onActivityResult(requestCode, resultCode, data);
204 + }
205 +
206 + @Override
207 + public void onConfigurationChanged(Configuration newConfig) {
208 + super.onConfigurationChanged(newConfig);
209 + PoolSdkHelper.onConfigurationChanged(newConfig);
210 + }
211 +
212 + @Override
213 + protected void onSaveInstanceState(Bundle outState) {
214 + super.onSaveInstanceState(outState);
215 + PoolSdkHelper.onSaveInstanceState(outState);
216 + }
217 +
218 + @Override
219 + protected void onRestoreInstanceState(Bundle savedInstanceState) {
220 + super.onRestoreInstanceState(savedInstanceState);
221 + PoolSdkHelper.onRestoreInstanceState(savedInstanceState);
222 + }
223 +
224 + @Override
225 + public void onWindowFocusChanged(boolean hasFocus) {
226 + super.onWindowFocusChanged(hasFocus);
227 + PoolSdkHelper.onWindowFocusChanged(hasFocus);
228 + }
229 +
230 + @Override
231 + public void onWindowAttributesChanged(LayoutParams params) {
232 + super.onWindowAttributesChanged(params);
233 + PoolSdkHelper.onWindowAttributesChanged(params);
234 + }
235 +
236 + @Override
237 + public boolean dispatchKeyEvent(KeyEvent pKeyEvent) {
238 + if (pKeyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK
239 + && pKeyEvent.getAction() == KeyEvent.ACTION_DOWN) {
240 + if (PoolSdkHelper.hasExitDialog()) {
241 + PoolSdkHelper.showExitDialog(new PoolExitDialogListener() {
242 + @Override
243 + public void onDialogResult(int code, String msg) {
244 + switch (code) {
245 + case PoolSDKCode.EXIT_SUCCESS:
246 + // 退出成功游戏处理自己退出逻辑
247 + PoolSdkLog.logInfo("游戏调用自己退出逻辑");
248 + finish();
249 + System.exit(0);
250 + break;
251 + case PoolSDKCode.EXIT_CANCEL:
252 + // 取消退出
253 + PoolSdkLog.logInfo("收到取消退出回调");
254 + break;
255 + default:
256 + break;
257 + }
258 + }
259 + });
260 + } else {
261 + // TODO: 调用游戏的退出界面
262 + showGameExitTips();
263 + }
264 + return false;
265 + }
266 + return super.dispatchKeyEvent(pKeyEvent);
267 + }
268 +
269 + private void showGameExitTips() {
270 + AlertDialog.Builder dialog = new AlertDialog.Builder(this);
271 + int ic_dialog_alert_id = getRedIdByName("ic_dialog_alert", "drawable");
272 + dialog.setIcon(ic_dialog_alert_id);
273 + dialog.setTitle("提示");
274 + dialog.setMessage("是否退出游戏?");
275 + dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
276 + @Override
277 + public void onClick(DialogInterface dialog, int which) {
278 + PoolSdkHelper.exitGame(new PoolExitListener() {
279 + @Override
280 + public void onExitGame() {
281 + finish();
282 + }
283 + });
284 + }
285 + });
286 + dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
287 + @Override
288 + public void onClick(DialogInterface dialog, int which) {
289 + dialog.dismiss();
290 + }
291 + });
292 + dialog.show();
293 + }
294 +
295 + private int getRedIdByName(String resName, String resType) {
296 + return getResources().getIdentifier(resName, resType, getPackageName());
297 + }
298 +
299 + private void initView(){
300 + btLogin = (Button) findViewById(getRedIdByName("pb_bt_login", "id"));
301 + btEnterGame = (Button) findViewById(getRedIdByName("pb_bt_entergame", "id"));
302 + btPay = (Button) findViewById(getRedIdByName("pb_bt_pay", "id"));
303 + btLogout = (Button) findViewById(getRedIdByName("pb_bt_logout", "id"));
304 + btSubRoleInfo = (Button) findViewById(getRedIdByName("pb_bt_subrole", "id"));
305 + btOpenChannel = (Button) findViewById(getRedIdByName("pb_bt_openchannel", "id"));
306 + btSwitchAcc = (Button) findViewById(getRedIdByName("pb_bt_switchacc", "id"));
307 + btOpenBbs = (Button) findViewById(getRedIdByName("pb_bt_openbbs", "id"));
308 +
309 + txMsg = (TextView) findViewById(getRedIdByName("tx_msg", "id"));
310 + txSdkMsg = (TextView) findViewById(getRedIdByName("tx_sdk_msg", "id"));
311 +
312 + btLogin.setOnClickListener(this);
313 + btEnterGame.setOnClickListener(this);
314 + btPay.setOnClickListener(this);
315 + btLogout.setOnClickListener(this);
316 + btSubRoleInfo.setOnClickListener(this);
317 + btOpenChannel.setOnClickListener(this);
318 + btSwitchAcc.setOnClickListener(this);
319 + btOpenBbs.setOnClickListener(this);
320 + }
321 +
322 + public void yaOnClick(View view) {
323 + }
324 +
325 + @Override
326 + public void onClick(View view) {
327 + //新view
328 + if (view == btLogin) {
329 + login();
330 + }else if (view == btEnterGame) {
331 + PoolReport.reportEnterGame("chufan","角色名", 12, "201","服务器名");
332 + }else if (view == btPay) {
333 + pay();
334 + }else if (view == btLogout) {
335 + logout();
336 + }else if (view == btSubRoleInfo) {
337 + submitRoleData();
338 + }else if (view == btOpenChannel) {
339 + channelCenter();
340 + }else if (view == btSwitchAcc) {
341 + switchAccount();
342 + }else if (view == btOpenBbs) {
343 + trackEvent();
344 + }
345 + }
346 +
347 + private void trackEvent(){
348 + Map<String,Object> valueMap = new HashMap<>();
349 + valueMap.put(PoolEventParameterName.POOL_ORDER_ID,System.currentTimeMillis()+"");//订单号
350 + valueMap.put(PoolEventParameterName.POOL_CURRENCY,"USD");//货币类型 USD:美元 CNY:人民币
351 + valueMap.put(PoolEventParameterName.POOL_PRICE,6);//充值金额
352 + PoolSdkHelper.trackEvent(getApplicationContext(), PoolEventType.POOL_RES_LOADED,valueMap);
353 + }
354 +
355 + private void logout(){
356 +// if(PoolSdkHelper.hasLogout()){
357 +// PoolSdkHelper.logout(this);//结果回调通知到PoolLogoutListener
358 +// }
359 + }
360 +
361 + private void upTx(final String msg){
362 + mContext.runOnUiThread(new Runnable() {
363 +
364 + @Override
365 + public void run() {
366 + txMsg.setText(msg);
367 + }
368 + });
369 +// new Handler().post(new Runnable() {
370 +//
371 +// @Override
372 +// public void run() {
373 +// txMsg.setText(msg);
374 +// }
375 +// });
376 + }
377 +
378 + private void login() {
379 + PoolSdkLog.logError("调用login");
380 + PoolSdkHelper.login("登录自定义字段", new PoolLoginListener() {
381 + @Override
382 + public void onLoginSuccess(PoolLoginInfo poolLoginInfo) {
383 + final String userType = poolLoginInfo.getUserType();
384 + final String timestamp = poolLoginInfo.getTimestamp();
385 + final String serverSign = poolLoginInfo.getServerSign();
386 + final String openId = poolLoginInfo.getOpenID();
387 + // TODO: 把以上信息发送给游戏服务端做登录校验,需要其他信息请从poolLoginInfo对象中获取
388 +
389 + System.out.println("登录成功回调:userType = " + userType
390 + + "; timestamp = " + timestamp + "; serverSign = "
391 + + serverSign + "; openId = " + openId);
392 + upTx("登录成功回调:userType = " + userType
393 + + "; timestamp = " + timestamp + "; serverSign = "
394 + + serverSign + "; openId = " + openId);
395 + }
396 +
397 + @Override
398 + public void onLoginFailed(final String errorMsg) {
399 + System.out.println("登录失败回调 :" + errorMsg);
400 + upTx("登录失败回调 :" + errorMsg);
401 + }
402 + });
403 +
404 +
405 + PoolPayOrderConfirmHandler.getInstance(this, 2000, 1000).startOrderConfirmOp(mPoolPayListener);
406 + }
407 +
408 + private void pay() {
409 + final PoolPayInfo poolPayInfo = new PoolPayInfo();
410 +
411 + /********************************************
412 + * 以下所有字段都是必填项
413 + */
414 + // 设置充值金额,单位“元”
415 + poolPayInfo.setAmount("100");
416 + // 服务器id
417 + poolPayInfo.setServerID("1209");
418 + // 服务器名
419 + poolPayInfo.setServerName("我是服务器名");
420 + // 角色id
421 + poolPayInfo.setRoleID("123456");
422 + // 角色名
423 + poolPayInfo.setRoleName("我是角色名");
424 + // 角色等级
425 + poolPayInfo.setRoleLevel("10");
426 + // 商品ID
427 + poolPayInfo.setProductID("1");
428 + // 商品名称
429 + poolPayInfo.setProductName("金币");
430 + // 商品描述
431 + poolPayInfo.setProductDesc("购买金币");
432 + // 兑换比例
433 + poolPayInfo.setExchange("10");
434 + // 自定义参数
435 + poolPayInfo.setCustom("我是自定义参数");
436 +
437 + // TODO Auto-generated method stub
438 + PoolSdkHelper.pay(poolPayInfo, mPoolPayListener);
439 + }
440 +
441 + /**
442 + * 提交角色数据 该接口需要在3个地方调用
443 + *
444 + * 1、登录游戏主场景 2、创建角色 3、角色升级
445 + */
446 + private void submitRoleData() {
447 + /********************************************
448 + * 以下所有字段都是必填项
449 + */
450 + final PoolRoleInfo poolRoleInfo = new PoolRoleInfo();
451 + poolRoleInfo.setRoleID("123456");
452 + poolRoleInfo.setRoleLevel("10");
453 + poolRoleInfo.setRoleSex("0");
454 + poolRoleInfo.setRoleName("我是角色名");
455 + poolRoleInfo.setServerID("1209");
456 + poolRoleInfo.setServerName("我是服务器名");
457 + poolRoleInfo.setCustom("角色创建时间");
458 + poolRoleInfo.setRoleCTime((long)1509331962);//角色创建时间(秒)
459 + poolRoleInfo.setPartyName("公会名称");
460 + poolRoleInfo.setRoleType("狂战");//角色类型
461 + poolRoleInfo.setRoleChangeTime(System.currentTimeMillis()/1000);//角色更新时间
462 + poolRoleInfo.setVipLevel("10");//vip等级
463 + poolRoleInfo.setDiamond("1000");//余额
464 + poolRoleInfo.setMoneyType("金币");//商品单位
465 +
466 + poolRoleInfo.setCallType(PoolRoleInfo.Type_EnterGame);
467 + // poolRoleInfo.setCallType(PoolRoleInfo.Type_CreateRole);
468 + // poolRoleInfo.setCallType(PoolRoleInfo.Type_RoleUpgrade);
469 +
470 + PoolSdkHelper.submitRoleData(poolRoleInfo, new PoolRoleListener() {
471 + @Override
472 + public void onRoleDataSuccess(String paramCustom) {
473 + System.out.println("提交角色数据成功:" + poolRoleInfo.verboseInfo());
474 + upTx("提交角色数据成功:" + poolRoleInfo.verboseInfo());
475 + }
476 + });
477 + }
478 +
479 + /**
480 + * 用户中心
481 + *
482 + * 游戏方先调用PoolSdkHelper.hasChannelCenter()获取是否有用户中心,
483 + * 如果有的话,游戏中需要添加按钮,点击按钮调用PoolSdkHelper.openChannelCenter();
484 + * 如果没有,则不需要显示按钮,也不用调用下面的接口
485 + */
486 + private void channelCenter() {
487 + PoolSdkHelper.openChannelCenter();
488 + }
489 +
490 + /**
491 + * 切换帐号
492 + */
493 + private void switchAccount() {
494 + if(PoolSdkHelper.hasLogout()){
495 + PoolSdkHelper.logout(this);//注销成功后结果回调通知到PoolLogoutListener中
496 + }else if(PoolSdkHelper.hasSwitchAccount()){
497 + PoolSdkHelper.switchAccount(this);//切换成功后回回调结果到登录成功通知中(与登录通知数据一样)
498 + }else{//渠道不存在注销和切换账号接口,游戏可自定处理逻辑
499 + }
500 + }
501 +
502 + /**
503 + * 扩展接口
504 + */
505 + private void expansionInterface() {
506 + PoolSdkHelper.expansionInterface("自定义参数", new PoolExpansionListener() {
507 + @Override
508 + public void onSuccess(String paramCustom) {
509 + }
510 + });
511 + }
512 +
513 +}
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:layout_width="fill_parent"
4 + android:layout_height="fill_parent"
5 + android:background="#FFFFFF"
6 + android:orientation="vertical"
7 + android:padding="5dp" >
8 +
9 + <LinearLayout
10 + android:layout_width="fill_parent"
11 + android:layout_height="wrap_content"
12 + android:orientation="horizontal" >
13 +
14 + <LinearLayout
15 + android:layout_width="0dp"
16 + android:layout_height="wrap_content"
17 + android:layout_margin="5dp"
18 + android:layout_weight="1"
19 + android:orientation="vertical" >
20 +
21 + <Button
22 + android:id="@+id/pb_bt_login"
23 + style="?android:attr/buttonStyleSmall"
24 + android:layout_width="fill_parent"
25 + android:layout_height="wrap_content"
26 + android:text="登录" />
27 +
28 + <Button
29 + android:id="@+id/pb_bt_entergame"
30 + style="?android:attr/buttonStyleSmall"
31 + android:layout_width="fill_parent"
32 + android:layout_height="wrap_content"
33 + android:text="进入游戏" />
34 +
35 + <Button
36 + android:id="@+id/pb_bt_pay"
37 + style="?android:attr/buttonStyleSmall"
38 + android:layout_width="fill_parent"
39 + android:layout_height="wrap_content"
40 + android:text="支付" />
41 +
42 + <Button
43 + android:id="@+id/pb_bt_logout"
44 + style="?android:attr/buttonStyleSmall"
45 + android:layout_width="fill_parent"
46 + android:layout_height="wrap_content"
47 + android:visibility="gone"
48 + android:text="注销" />
49 + </LinearLayout>
50 +
51 + <LinearLayout
52 + android:layout_width="0dp"
53 + android:layout_height="wrap_content"
54 + android:layout_margin="5dp"
55 + android:layout_weight="1"
56 + android:orientation="vertical" >
57 +
58 + <Button
59 + android:id="@+id/pb_bt_subrole"
60 + style="?android:attr/buttonStyleSmall"
61 + android:layout_width="fill_parent"
62 + android:layout_height="wrap_content"
63 + android:text="提交角色数据" />
64 +
65 + <Button
66 + android:id="@+id/pb_bt_openchannel"
67 + style="?android:attr/buttonStyleSmall"
68 + android:layout_width="fill_parent"
69 + android:layout_height="wrap_content"
70 + android:text="打开渠道个人中心" />
71 +
72 + <Button
73 + android:id="@+id/pb_bt_switchacc"
74 + style="?android:attr/buttonStyleSmall"
75 + android:layout_width="fill_parent"
76 + android:layout_height="wrap_content"
77 + android:text="切换账号" />
78 +
79 + <Button
80 + android:id="@+id/pb_bt_openbbs"
81 + style="?android:attr/buttonStyleSmall"
82 + android:layout_width="fill_parent"
83 + android:layout_height="wrap_content"
84 + android:text="事件上报" />
85 + </LinearLayout>
86 + </LinearLayout>
87 +
88 + <TextView
89 + android:layout_width="fill_parent"
90 + android:layout_height="wrap_content"
91 + android:layout_gravity="center"
92 + android:layout_margin="10dp"
93 + android:gravity="center"
94 + />
95 +
96 + <TextView
97 + android:id="@+id/tx_sdk_msg"
98 + android:layout_width="fill_parent"
99 + android:layout_height="wrap_content"
100 + android:layout_margin="10dp" />
101 +
102 + <TextView
103 + android:id="@+id/tx_msg"
104 + android:layout_width="fill_parent"
105 + android:layout_height="wrap_content"
106 + android:layout_margin="10dp" />
107 +
108 +</LinearLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<resources>
3 +
4 + <string name="app_name">Demo_shenshou</string>
5 +
6 +</resources>
1 +// Top-level build file where you can add configuration options common to all sub-projects/modules.
2 +
3 +buildscript {
4 + repositories {
5 + google()
6 + jcenter()
7 +
8 + }
9 + dependencies {
10 + classpath 'com.android.tools.build:gradle:3.3.1'
11 +
12 + // NOTE: Do not place your application dependencies here; they belong
13 + // in the individual module build.gradle files
14 + }
15 +}
16 +
17 +allprojects {
18 + repositories {
19 + google()
20 + jcenter()
21 +
22 + }
23 +}
24 +
25 +task clean(type: Delete) {
26 + delete rootProject.buildDir
27 +}
1 +# Project-wide Gradle settings.
2 +# IDE (e.g. Android Studio) users:
3 +# Gradle settings configured through the IDE *will override*
4 +# any settings specified in this file.
5 +# For more details on how to configure your build environment visit
6 +# http://www.gradle.org/docs/current/userguide/build_environment.html
7 +# Specifies the JVM arguments used for the daemon process.
8 +# The setting is particularly useful for tweaking memory settings.
9 +org.gradle.jvmargs=-Xmx1536m
10 +# When configured, Gradle will run in incubating parallel mode.
11 +# This option should only be used with decoupled projects. More details, visit
12 +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 +# org.gradle.parallel=true
14 +
15 +
No preview for this file type
1 +#Tue Oct 29 15:45:22 CST 2019
2 +distributionBase=GRADLE_USER_HOME
3 +distributionPath=wrapper/dists
4 +zipStoreBase=GRADLE_USER_HOME
5 +zipStorePath=wrapper/dists
6 +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
1 +#!/usr/bin/env sh
2 +
3 +##############################################################################
4 +##
5 +## Gradle start up script for UN*X
6 +##
7 +##############################################################################
8 +
9 +# Attempt to set APP_HOME
10 +# Resolve links: $0 may be a link
11 +PRG="$0"
12 +# Need this for relative symlinks.
13 +while [ -h "$PRG" ] ; do
14 + ls=`ls -ld "$PRG"`
15 + link=`expr "$ls" : '.*-> \(.*\)$'`
16 + if expr "$link" : '/.*' > /dev/null; then
17 + PRG="$link"
18 + else
19 + PRG=`dirname "$PRG"`"/$link"
20 + fi
21 +done
22 +SAVED="`pwd`"
23 +cd "`dirname \"$PRG\"`/" >/dev/null
24 +APP_HOME="`pwd -P`"
25 +cd "$SAVED" >/dev/null
26 +
27 +APP_NAME="Gradle"
28 +APP_BASE_NAME=`basename "$0"`
29 +
30 +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 +DEFAULT_JVM_OPTS=""
32 +
33 +# Use the maximum available, or set MAX_FD != -1 to use that value.
34 +MAX_FD="maximum"
35 +
36 +warn () {
37 + echo "$*"
38 +}
39 +
40 +die () {
41 + echo
42 + echo "$*"
43 + echo
44 + exit 1
45 +}
46 +
47 +# OS specific support (must be 'true' or 'false').
48 +cygwin=false
49 +msys=false
50 +darwin=false
51 +nonstop=false
52 +case "`uname`" in
53 + CYGWIN* )
54 + cygwin=true
55 + ;;
56 + Darwin* )
57 + darwin=true
58 + ;;
59 + MINGW* )
60 + msys=true
61 + ;;
62 + NONSTOP* )
63 + nonstop=true
64 + ;;
65 +esac
66 +
67 +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 +
69 +# Determine the Java command to use to start the JVM.
70 +if [ -n "$JAVA_HOME" ] ; then
71 + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 + # IBM's JDK on AIX uses strange locations for the executables
73 + JAVACMD="$JAVA_HOME/jre/sh/java"
74 + else
75 + JAVACMD="$JAVA_HOME/bin/java"
76 + fi
77 + if [ ! -x "$JAVACMD" ] ; then
78 + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 +
80 +Please set the JAVA_HOME variable in your environment to match the
81 +location of your Java installation."
82 + fi
83 +else
84 + JAVACMD="java"
85 + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 +
87 +Please set the JAVA_HOME variable in your environment to match the
88 +location of your Java installation."
89 +fi
90 +
91 +# Increase the maximum file descriptors if we can.
92 +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 + MAX_FD_LIMIT=`ulimit -H -n`
94 + if [ $? -eq 0 ] ; then
95 + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 + MAX_FD="$MAX_FD_LIMIT"
97 + fi
98 + ulimit -n $MAX_FD
99 + if [ $? -ne 0 ] ; then
100 + warn "Could not set maximum file descriptor limit: $MAX_FD"
101 + fi
102 + else
103 + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 + fi
105 +fi
106 +
107 +# For Darwin, add options to specify how the application appears in the dock
108 +if $darwin; then
109 + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 +fi
111 +
112 +# For Cygwin, switch paths to Windows format before running java
113 +if $cygwin ; then
114 + APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 + JAVACMD=`cygpath --unix "$JAVACMD"`
117 +
118 + # We build the pattern for arguments to be converted via cygpath
119 + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 + SEP=""
121 + for dir in $ROOTDIRSRAW ; do
122 + ROOTDIRS="$ROOTDIRS$SEP$dir"
123 + SEP="|"
124 + done
125 + OURCYGPATTERN="(^($ROOTDIRS))"
126 + # Add a user-defined pattern to the cygpath arguments
127 + if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 + fi
130 + # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 + i=0
132 + for arg in "$@" ; do
133 + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 +
136 + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 + else
139 + eval `echo args$i`="\"$arg\""
140 + fi
141 + i=$((i+1))
142 + done
143 + case $i in
144 + (0) set -- ;;
145 + (1) set -- "$args0" ;;
146 + (2) set -- "$args0" "$args1" ;;
147 + (3) set -- "$args0" "$args1" "$args2" ;;
148 + (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 + esac
155 +fi
156 +
157 +# Escape application args
158 +save () {
159 + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 + echo " "
161 +}
162 +APP_ARGS=$(save "$@")
163 +
164 +# Collect all arguments for the java command, following the shell quoting and substitution rules
165 +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 +
167 +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 + cd "$(dirname "$0")"
170 +fi
171 +
172 +exec "$JAVACMD" "$@"
1 +@if "%DEBUG%" == "" @echo off
2 +@rem ##########################################################################
3 +@rem
4 +@rem Gradle startup script for Windows
5 +@rem
6 +@rem ##########################################################################
7 +
8 +@rem Set local scope for the variables with windows NT shell
9 +if "%OS%"=="Windows_NT" setlocal
10 +
11 +set DIRNAME=%~dp0
12 +if "%DIRNAME%" == "" set DIRNAME=.
13 +set APP_BASE_NAME=%~n0
14 +set APP_HOME=%DIRNAME%
15 +
16 +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 +set DEFAULT_JVM_OPTS=
18 +
19 +@rem Find java.exe
20 +if defined JAVA_HOME goto findJavaFromJavaHome
21 +
22 +set JAVA_EXE=java.exe
23 +%JAVA_EXE% -version >NUL 2>&1
24 +if "%ERRORLEVEL%" == "0" goto init
25 +
26 +echo.
27 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 +echo.
29 +echo Please set the JAVA_HOME variable in your environment to match the
30 +echo location of your Java installation.
31 +
32 +goto fail
33 +
34 +:findJavaFromJavaHome
35 +set JAVA_HOME=%JAVA_HOME:"=%
36 +set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 +
38 +if exist "%JAVA_EXE%" goto init
39 +
40 +echo.
41 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 +echo.
43 +echo Please set the JAVA_HOME variable in your environment to match the
44 +echo location of your Java installation.
45 +
46 +goto fail
47 +
48 +:init
49 +@rem Get command-line arguments, handling Windows variants
50 +
51 +if not "%OS%" == "Windows_NT" goto win9xME_args
52 +
53 +:win9xME_args
54 +@rem Slurp the command line arguments.
55 +set CMD_LINE_ARGS=
56 +set _SKIP=2
57 +
58 +:win9xME_args_slurp
59 +if "x%~1" == "x" goto execute
60 +
61 +set CMD_LINE_ARGS=%*
62 +
63 +:execute
64 +@rem Setup the command line
65 +
66 +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 +
68 +@rem Execute Gradle
69 +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 +
71 +:end
72 +@rem End local scope for the variables with windows NT shell
73 +if "%ERRORLEVEL%"=="0" goto mainEnd
74 +
75 +:fail
76 +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 +rem the _cmd.exe /c_ return code!
78 +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 +exit /b 1
80 +
81 +:mainEnd
82 +if "%OS%"=="Windows_NT" endlocal
83 +
84 +:omega
1 +include ':app'
1 +# 公共SDK接入文档 #
2 +
3 +## 接入必读
4 +`注意!cp需在获取以下权限收到回调后才能调用公共的其他api接口
5 +android.permission.WRITE_EXTERNAL_STORAGE
6 +android.permission.READ_PHONE_STATE`
7 +
8 +`
9 +接入公共SDK测试没问题后游戏打出一个母包,需要上哪个渠道使用打包工具进行打对应渠道包。
10 +`
11 +
12 +## 1、开发环境搭建 ##
13 +以下是以 Eclipse 为例,在 Eclipse 环境下开发的 SDK 配置(AS接入方式一样)
14 +
15 +#### 1.1、将 SDK 压缩包中 libs 目录下的所有 资源 包复制到游戏工程的libs 目录下 ####
16 +
17 +#### 1.2、复制SDK压缩包中assets目录下的所有内容到游戏工程的assets目录 ####
18 +
19 +- 将游戏中的闪屏图片放到assets中poolsdk_splash目录下(选用,图片文件名任意,最多支持2张闪屏)
20 +- 将assets中的poolsdk.xml文件替换(具体文件请与相关人员申请)
21 +
22 +#### 1.3、修改游戏工程的AndroidManifest.xml(可以参照复制Demo中 AndroidManifest.xml文件) ####
23 +
24 +- 添加声明权限:
25 +
26 +```
27 + <uses-permission android:name="android.permission.INTERNET" />
28 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
29 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
30 + <uses-permission android:name="android.permission.READ_PHONE_STATE" />
31 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
32 +```
33 +
34 +
35 +### 2、功能接口 (注意:以下所有接口都必须在 SDK 初始化完成之后才能调用) ###
36 +
37 +
38 +#### 2.1、继承 PoolSDKApplication(必接)
39 +
40 +游戏工程如果没有Application,请在 AndroidManifest.xml 中添加SDK的Application,如下所示:
41 +
42 +```xml
43 +<application android:name="com.gzpublic.app.sdk.application.PoolSDKApplication">
44 +```
45 +
46 +游戏工程如果有 Application,请继承 SDK 中 PoolSDKApplication:
47 +
48 +```java
49 + public class XXXXApplication extends PoolSDKApplication {
50 + @Override
51 + public void onCreate() {
52 + // TODO Auto-generated method stub
53 + super.onCreate();
54 + }
55 + }
56 +```
57 +#### 2.2、初始化接口(必接)
58 + 接口说明:
59 + 首先在程序开始的地方调用 SDK 的初始化 init 方法,并设 置 Activity 对像和初始化完成回调
60 + 监听(在初始化失败情况下不 再调用其它 SDK 接口方法)
61 + 注意:要确保在 SDK 初始化成功后才可调用其它接口
62 + 2.2.1、方法定义
63 + public static void init(final Activity activity,final PoolSDKCallBackListener callBackListener)
64 +
65 +#### 2.2.2、参数说明
66 +
67 +| 参数 | 说明 |
68 +| ---------------- | -------------------------------- |
69 +| activity | Activity 对应 |
70 +| callBackListener | 初始化完成回调通知,需实现 poolSdkCallBack 方法 |
71 +
72 +```java
73 + 2.2.3、代码示例:
74 + PoolSdkHelper.init(this, new PoolSDKCallBackListener() {
75 + @Override
76 + public void poolSdkCallBack(int code, String msg) {
77 + // TODO Auto-generated method stub
78 + PoolSdkLog.logInfo("callback: code:" + code + "msg:" + msg);
79 + switch (code) {
80 + case PoolSDKCode.POOLSDK_INIT_SUCCESS:// 初始化成功
81 + PoolSdkLog.logInfo("游戏中POOLSDK_INIT_SUCCESS");
82 + login();
83 + break;
84 + case PoolSDKCode.POOLSDK_INIT_FAIL:
85 + break;
86 + }
87 + }
88 + });
89 +
90 +```
91 +#### 2.3、登录接口(必接)
92 +
93 +接口说明:游戏登录时调用
94 +
95 +#### 2.3.1、方法定义
96 +
97 +```java
98 +public static void login(final String paramCustom,final PoolLoginListener poolLoginListener)
99 +```
100 +
101 +#### 2.3.2、参数说明
102 +
103 +| 参数 | 说明 |
104 +| ----------------- | ---------------------------------------- |
105 +| paramCustom | 游戏自定义参数,可通过登录成功回调方法onLoginSuccess 中的参数PoolLoginInfo 对象的 getCustom()获取 |
106 +| poolLoginListener | 登录结果回调通知,需实现 onLoginSuccess 方法 |
107 +
108 +
109 +```java
110 + 2.3.3、代码示例
111 + PoolSdkHelper.login("登录自定义字段", new PoolLoginListener() {
112 + @Override
113 + public void onLoginSuccess(PoolLoginInfo poolLoginInfo) {
114 + String userType = poolLoginInfo.getUserType();
115 + String timestamp = poolLoginInfo.getTimestamp();
116 + String serverSign = poolLoginInfo.getServerSign();
117 + String openId = poolLoginInfo.getOpenID();
118 + //把以上信息发送给游戏服务端做登录校验,需要其他信息请从poolLoginInfo对象中获取
119 + System.out.println("登录成功 userType = " + userType
120 + + "; timestamp = " + timestamp + "; serverSign = "
121 + + serverSign + "; openId = " + openId);
122 + }
123 + @Override
124 + public void onLoginFailed(String errorMsg) {
125 + System.out.println("登录失败 = " + errorMsg);
126 + }
127 + });
128 +
129 +```
130 +
131 +#### 2.4、提交角色数据接口(必接)
132 +接口说明:游戏提交角色数据接口,该接口需要在以下3中情况下调用:
133 +
134 +进入游戏主场景、创建角色、角色升级
135 +
136 +**(如果游戏创建角色时没有角色名,需要在用户创建角色名时调用多一次进入游戏统计,否则用户名无法正常统计,投放测试无法通过)**
137 +
138 +#### 2.4.1、方法定义
139 +
140 +```java
141 +public static void submitRoleData(final PoolRoleInfo poolRoleInfo,final PoolRoleListener poolRoleListener)
142 +```
143 +#### 2.4.2、参数说明
144 +
145 +| 参数 | 说明 |
146 +| ---------------- | ---------------- |
147 +| poolRoleInfo | 角色数据实体类 |
148 +| poolRoleListener | 角色数据提交结果回调通知,需实现 |
149 +
150 + PoolRoleInfo 实体类字段说明(以下参数都为必传参数,如游戏没有的传 "无" 或者 "0")
151 +| 字段名 | 说明 |
152 +| -------------- | ---------------------------------------- |
153 +| callType | 调用类型Type_EnterGame 登录游戏主 场景;Type_CreatRole 为创建角 色;Type_RoleUpgrade 为角色升级 |
154 +| roleId | 角色 Id(请用数字) |
155 +| roleName | 角色名称 |
156 +| roleLevel | 角色等级 (请用数字) |
157 +| roleSex | 角色性别(1 男 0 女,如果角 色不分性别请填写 0) |
158 +| serverId | 服务器 id (请用数字) |
159 +| serverName | 服务器名称 |
160 +| custom | 自定义字段 |
161 +| roleCTime | 角色创建时的时间戳(以秒为单位) (请用数字) |
162 +| partyName | 公会名称 (没有的传 "无") |
163 +| roleType | 角色类型 (没有的传 "无") |
164 +| roleChangeTime | 角色等级变化时的时间戳(以秒为单位) (请用数字) |
165 +| vipLevel | VIP等级 (请用数字,如无请传"0") |
166 +| diamond | 余额 (请用数字,如无请传"0") |
167 +| moneyType | 商品单位 (如 "钻石"、"金币"、"水晶"等) |
168 +
169 +
170 +```java
171 + 2.4.3、代码示例
172 + /********************************************
173 + * 以下所有字段都是必填项
174 + */
175 + PoolRoleInfo poolRoleInfo = new PoolRoleInfo();
176 + poolRoleInfo.setRoleID("123456");
177 + poolRoleInfo.setRoleLevel("10");
178 + poolRoleInfo.setRoleSex("0");
179 + poolRoleInfo.setRoleName("我是角色名");
180 + poolRoleInfo.setServerID("1");
181 + poolRoleInfo.setServerName("我是服务器名");
182 + poolRoleInfo.setCustom("角色创建时间");
183 + poolRoleInfo.setRoleCTime(System.currentTimeMillis()/1000);//角色创建时(秒)
184 + poolRoleInfo.setPartyName("公会名称");
185 + poolRoleInfo.setRoleType("狂战");//角色类型
186 + poolRoleInfo.setRoleChangeTime(System.currentTimeMillis()/1000);//角色更新时间
187 + poolRoleInfo.setVipLevel("10");//vip等级
188 + poolRoleInfo.setDiamond("1000");//余额
189 + poolRoleInfo.setMoneyType("金币");//商品单位
190 + poolRoleInfo.setCallType(PoolRoleInfo.Type_EnterGame);//进入游戏(第一次创建角色后需再调用一次进入游戏)
191 + // poolRoleInfo.setCallType(PoolRoleInfo.Type_CreateRole);//创建角色(如果游戏创建角色时没有角色名,需要在用户创建角色名时调用多一次进入游戏统计,否则用户名无法正常统计,投放测试无法通过)
192 + // poolRoleInfo.setCallType(PoolRoleInfo.Type_RoleUpgrade);//角色升级
193 +
194 + PoolSdkHelper.submitRoleData(poolRoleInfo, new PoolRoleListener() {
195 + @Override
196 + public void onRoleDataSuccess(String paramCustom) {
197 + System.out.println("提交角色数据成功 = " + paramCustom);
198 + }
199 + });
200 +
201 +```
202 +
203 +#### 2.5、支付接口(必接)
204 +
205 +#### 2.5.1、方法定义
206 +```java
207 +public static void pay(final PoolPayInfo poolPayInfo,final PoolPayListener poolPayListener)
208 +```
209 +
210 +#### 2.5.2、参数说明
211 +
212 +| 参数 | 说明 |
213 +| ---------------- | ---------------- |
214 +| poolRoleInfo | 角色数据实体类 |
215 +| poolRoleListener | 角色数据提交结果回调通知,需实现 |
216 +
217 + 支付信息实体类(PoolPayInfo)字段说明
218 +| 参数 | 说明 |
219 +| ----------- | ------------------- |
220 +| amount | 金额(单位元,必须大于 0,需传入整型数据`传小数时兑换比例和金额相乘为整数`) |
221 +| productId | 商品 ID(如果没有可以传空字符 串) |
222 +| productName | 商品描述 |
223 +| roleid | 角色 id |
224 +| rolelevel | 角色等级 |
225 +| roleName | 角色名称 |
226 +| serverId | 服务器 id |
227 +| serverName | 服务器名称 |
228 +| exchange | 游戏币与人民币(元)的兑换比例 `单机游戏时直接传对应购买的道具数量或游戏币数量` |
229 +| custom | 自定义透传参数,通过回调函数原样返回 |
230 +
231 +
232 +```java
233 + 2.5.3、代码示例
234 + /********************************************
235 + * 以下所有字段都是必填项
236 + */
237 + // 设置充值金额,单位“元”
238 + poolPayInfo.setAmount("1");
239 + // 服务器id
240 + poolPayInfo.setServerID("8");
241 + // 服务器名
242 + poolPayInfo.setServerName("我是服务器名");
243 + // 角色id
244 + poolPayInfo.setRoleID("123456");
245 + // 角色名
246 + poolPayInfo.setRoleName("我是角色名");
247 + // 角色等级
248 + poolPayInfo.setRoleLevel("10");
249 + // 商品ID
250 + poolPayInfo.setProductID("1");
251 + // 商品名称
252 + poolPayInfo.setProductName("金币");
253 + // 商品描述
254 + poolPayInfo.setProductDesc("购买金币");
255 + // 兑换比例
256 + poolPayInfo.setExchange("10");
257 + // 自定义参数
258 + poolPayInfo.setCustom("我是自定义参数");
259 + // 充值回调以服务端回调为准
260 + PoolSdkHelper.pay(poolPayInfo, new PoolPayListener() {
261 + @Override
262 + public void onPaySuccess(String paramCustom) {
263 + System.out.println("支付成功 = " + paramCustom);
264 + }
265 + @Override
266 + public void onPayFailed(String paramCustom, String errorMsg) {
267 + System.out.println("支付失败 = " + paramCustom + "; errorMsg = "
268 + + errorMsg);
269 + }
270 + });
271 +```
272 +
273 +#### 2.6、检测 SDK 是否含有用户中心接口(必接)
274 +
275 +说明:如果接口返回为 true,表示需要游戏方在合适的界面中添加一个用户中心的按钮,点击按钮时调用文档中 2.7 的用户中心接口;
276 +
277 +如果返回 false,则不做处理
278 +
279 +#### 2.6.1、方法定义
280 +```java
281 +public static boolean hasChannelCenter()
282 +```
283 +#### 2.7、用户中心接口(必接)
284 +
285 +说明:打开渠道用户中心界面
286 +
287 +#### 2.7.1、方法定义
288 +```java
289 +public static void openChannelCenter()
290 +```
291 +
292 +```java
293 +
294 + 2.7.2、代码示例
295 + /**
296 + * 用户中心
297 + *
298 + * 游戏方先调用PoolSdkHelper.hasChannelCenter()获取是否有用户中心,
299 + * 如果有的话,游戏中需要添加按钮,点击按钮调用PoolSdkHelper.openChannelCenter();
300 + * 如果没有,则不需要显示按钮,也不用调用下面的接口
301 + */
302 + private void channelCenter() {
303 + PoolSdkHelper.openChannelCenter();
304 + }
305 +
306 +```
307 +#### 2.8、注销登录监听接口
308 +
309 +说明:可在游戏启动时设置注销监听事件,渠道注销成功后 SDK 会回调 onLogoutSuccess 方法通知游戏,游戏可在此处理切换账号逻辑
310 +
311 +#### 2.8.1、方法定义
312 +
313 +```java
314 +public static void setLogoutCallback(final PoolLogoutListener poolLogoutListener)
315 +```
316 +
317 +#### 2.8.2、参数说明 ####
318 +
319 +| 参数 | 说明 |
320 +| ------------------ | --------------------------------- |
321 +| poolLogoutListener | 账户注销成功回调监听,需实现 onLogoutSuccess 方法 |
322 +
323 +
324 +```java
325 + 2.8.3、代码示例
326 + PoolSdkHelper.setLogoutCallback(new PoolLogoutListener() {
327 + @Override
328 + public void onLogoutSuccess() {
329 + // TODO: 此处处理SDK注销成功后的逻辑
330 + login();
331 + PoolSdkLog.logInfo("游戏中logoutSuccess");
332 + }
333 + });
334 +```
335 +
336 +### 2.9、切换账号接口
337 +
338 +说明: 该接口包含有注销和切换账号两种方式, 游戏需要根据同时根据两种接口的逻辑进行处理和调用
339 +
340 +1、当渠道走的是注销逻辑则成功后会回调到注销监听中,游戏可在对应回调中进行注销逻辑处理
341 +
342 +2、当渠道走的是切换账号逻辑时,在切换账号成功后会回调到登录成功的监听结果中
343 +
344 +
345 +#### 2.9.1、方法定义
346 +```java
347 +public static boolean hasLogout();
348 +public static void logout(final Activity paramActivity) ;
349 +public static boolean hasSwitchAccount();
350 +public static void switchAccount(final Activity paramActivity);
351 +```
352 +
353 +#### 2.9.2、 代码示例
354 +
355 +```java
356 +
357 + /**
358 + * 处理是否显示切换账号入口
359 + */
360 + if(PoolSdkHelper.hasLogout() || PoolSdkHelper.hasSwitchAccount()){
361 + //满足此条件时游戏显示切换账号功能入口
362 + }else{//不存在切换账号接口,游戏可自行处理对应逻辑
363 + }
364 +
365 + /**
366 + * 切换账号功能实现
367 + */
368 + if(PoolSdkHelper.hasLogout()){
369 + //结果在注销监听回调中处理(参考文档2.8、注销登录监听接口)
370 + PoolSdkHelper.logout(paramActivity);
371 + }else if(PoolSdkHelper.hasSwitchAccount()){
372 + //切换账号结果在登陆回调中处理
373 + PoolSdkHelper.switchAccount(paramActivity);
374 + }
375 +```
376 +
377 +
378 +#### 2.10、退出游戏接口(必接)
379 +
380 + 说明:在游戏需要退出时调用,调用此接口时需先用 PoolSdkHelper.hasExitDialog() 判断 sdk 是否有退出界
381 + 面,为 true表示有退出界面需调用 showExitDialog()显示退出界面,为 false 时表示没有退出界面,游戏需自己处
382 + 理退出逻辑且在确认 游戏退出前调用 PoolSdkHelper.exitGame 通知 SDK 游戏要退出 (具体可参照 Demo 示例)
383 +
384 +#### 2.10.1、方法定义
385 +```java
386 +public static void showExitDialog(final PoolExitDialogListener exitDialogListener)
387 +```
388 +
389 +#### 2.10.2、参数说明
390 +
391 +| 参数 | 说明 |
392 +| ------------------ | ------------------------------ |
393 +| exitDialogListener | 退出结果回调监听,需实现 onDialogResult 方法 |
394 +
395 +```java
396 + 2.9.3、代码示例
397 + @Override
398 + public boolean dispatchKeyEvent(KeyEvent pKeyEvent) {
399 + if (pKeyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK
400 + && pKeyEvent.getAction() == KeyEvent.ACTION_DOWN) {
401 + if (PoolSdkHelper.hasExitDialog()) {
402 + PoolSdkHelper.showExitDialog(new PoolExitDialogListener() {
403 + @Override
404 + public void onDialogResult(int code, String msg) {
405 + // TODO Auto-generated method stub
406 + switch (code) {
407 + case PoolSDKCode.EXIT_SUCCESS:// 退出成功游戏处理自己退出逻辑
408 + finish();
409 + // System.exit(0);
410 + break;
411 + case PoolSDKCode.EXIT_CANCEL:// 取消退出
412 + break;
413 + default:
414 + break;
415 + }
416 + }
417 + });
418 + } else {
419 + // TODO: 调用游戏的退出界面
420 + showGameExitTips();
421 + }
422 + return false;
423 + }
424 + return super.dispatchKeyEvent(pKeyEvent);
425 + }
426 +```
427 +
428 +### 2.11、Android 生命周期接口(必接) ###
429 + 说明:在游戏 Activity 的 onStart、onPause、onResume、 onStop、onDestroy、onRestart、onNewIntent、 onActivityResult、onConfigurationChanged、onSaveInstanceState、onRestoreInstanceState、onWindowFocusChanged、onWindowAttributesChanged 中分别调用对应的接口
430 +
431 +```java
432 + 2.10.1 代码示例
433 + @Override
434 + public void onStart() {
435 + super.onStart();
436 + PoolSdkHelper.onStart();
437 + }
438 +
439 + @Override
440 + public void onStop() {
441 + super.onStop();
442 + PoolSdkHelper.onStop();
443 + }
444 +
445 + @Override
446 + public void onDestroy() {
447 + super.onDestroy();
448 + PoolSdkHelper.onDestroy();
449 + }
450 +
451 + @Override
452 + public void onResume() {
453 + super.onResume();
454 + PoolSdkHelper.onResume();
455 + }
456 +
457 + @Override
458 + public void onPause() {
459 + super.onPause();
460 + PoolSdkHelper.onPause();
461 + }
462 +
463 + @Override
464 + public void onRestart() {
465 + super.onRestart();
466 + PoolSdkHelper.onRestart();
467 + }
468 +
469 + @Override
470 + public void onNewIntent(Intent intent) {
471 + super.onNewIntent(intent);
472 + PoolSdkHelper.onNewIntent(intent);
473 + }
474 +
475 + @Override
476 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
477 + PoolSdkHelper.onActivityResult(requestCode, resultCode, data);
478 + }
479 +
480 + @Override
481 + public void onConfigurationChanged(Configuration newConfig) {
482 + // TODO Auto-generated method stub
483 + super.onConfigurationChanged(newConfig);
484 + PoolSdkHelper.onConfigurationChanged(newConfig);
485 + }
486 +
487 + @Override
488 + protected void onSaveInstanceState(Bundle outState) {
489 + // TODO Auto-generated method stub
490 + super.onSaveInstanceState(outState);
491 + PoolSdkHelper.onSaveInstanceState(outState);
492 + }
493 +
494 + @Override
495 + protected void onRestoreInstanceState(Bundle savedInstanceState) {
496 + // TODO Auto-generated method stub
497 + super.onRestoreInstanceState(savedInstanceState);
498 + PoolSdkHelper.onRestoreInstanceState(savedInstanceState);
499 + }
500 +
501 + @Override
502 + public void onWindowFocusChanged(boolean hasFocus) {
503 + // TODO Auto-generated method stub
504 + super.onWindowFocusChanged(hasFocus);
505 + PoolSdkHelper.onWindowFocusChanged(hasFocus);
506 + }
507 +
508 + @Override
509 + public void onWindowAttributesChanged(LayoutParams params) {
510 + // TODO Auto-generated method stub
511 + super.onWindowAttributesChanged(params);
512 + PoolSdkHelper.onWindowAttributesChanged(params);
513 + }
514 +
515 + @Override
516 + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
517 + // TODO Auto-generated method stub
518 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
519 + PoolSdkHelper.onRequestPermissionsResult(requestCode, permissions, grantResults);
520 + }
521 +```
522 +
523 +### 2.12、扩展接口(可选) ###
524 + 说明:该接口为扩展的万能接口,留作备用,目前游戏方可以不接入
525 + 2.11.1、方法定义
526 + public static void expansionInterface(final String paramCustom,final PoolExpansionListener poolExpansionListener)
527 + 2.11.2、参数说明
528 +| 参数 | 说明 |
529 +| --------------------- | -------------------- |
530 +| paramCustom | 自定义参数 |
531 +| poolExpansionListener | 方法回调参数,实现onSuccess方法 |
532 +
533 +### 2.13、获取渠道包标识(可选) ###
534 + 接口名称:PoolSdkHelper.getGameChannelId()
535 + 接口说明:获取在企业平台配置的渠道标识,返回类型为 String
536 + 接口名称:PoolSdkHelper. getChannelParameter1 ()
537 + 接口说明:获取在企业平台配置的渠道参数 1,返回类型为 String
538 + 接口名称:PoolSdkHelper. getChannelParameter2 ()
539 + 接口说明:获取在企业平台配置的渠道参数 2,返回类型为 String
540 +### 2.14、获取渠道自定义参数(可选) ###
541 + 接口名称:PoolSdkHelper.getCustomValue()
542 + 接口说明:获取在企业平台配置的渠道自定义参数,返回类型为 String
543 +### 2.15、打开论坛、社区接口 ###
544 + 接口名称:PoolSkHelper.openForum()
545 + 接口说明:打开渠道的论坛界面
546 +
547 +
548 +### 2.16、聊天统计 ###
549 +
550 +说明:在用户发送聊天信息时调用该接口
551 +
552 +```java
553 +public static void reportChat(final String content,String typefinal String accountId,final String accountName, final int level, final String serverId,final String serverName)
554 +```
555 +参数说明:
556 +
557 +参数 |说明
558 +------------ | -------------
559 +content | 聊天内容
560 +type | 聊天类型(世界,私聊等)
561 +accountId | 角色ID
562 +accountName | 角色名称
563 +level | 角色等级
564 +serverId | 服务器ID
565 +serverName | 服务器名称
566 +
567 +### 2.17、实名认证(防沉迷)接口 ###
568 +
569 +说明:游戏方需要渠道SDK实名认证信息时调用(请在登陆成功后再调用)
570 +
571 +```java
572 +public String verifyRealName(Activity paramActivity)
573 +```
574 +
575 +默认返回 "" (空字符串)为渠道SDK没有实名认证接口,游戏方需要自己实现该功能
576 +
577 +返回 "0" (字符串)为渠道有实名未认证,但该玩家未认证
578 +
579 +如果有实名认证接口,渠道有返回生日则返回生日(如"19900101")
580 +
581 +没有请运营跟渠道确认,到底返回成年日期还是未成年日期2.18、事件上报接口
582 +
583 +```
584 +/**
585 + * @param context 传getApplicationContext()
586 + * @param eventType 事件类型(PoolEventType类中获取对应事件类型)
587 + * @param eventValue 参数值(充值时传PoolEventParameterName属性变量键值对)
588 + */
589 +public static void trackEvent(Context context, String eventType, Map<String, Object> eventValue);
590 +```
591 +
592 +游戏许上报的事件类型有:
593 +```
594 +PoolEventType类中对应的类型:
595 + POOL_RES_LOADED 资源加载完毕
596 + POOL_TUTORIAL_COMPLETION 新手流程结束
597 + POOL_FIRST_DAY_CHECKPOINT_TO_VALUE 副本关卡(创角首日达到的某个关卡)(具体关卡cp跟渠道沟通)
598 + POOL_ENTER_PARTY 加入公会/联盟等
599 + POOL_FIRST_DAY_UPDATE_TO_LEVEL1 首日更新到某个等级(具体等级cp跟渠道沟通)
600 + POOL_FIRST_RECHARGE 首冲
601 + POOL_PAY_SUCCESS 充值成功
602 + POOL_FIRST_DAY_RECHARGE_TO_VALUE 首日充值达到某个值时(具体数值cp跟渠道沟通)
603 + POOL_BUY_MOUTH_CARD 购买月卡
604 + POOL_BIG_RECHARGE 累积充值达到某个数额(具体数值cp跟渠道沟通)
605 + POOL_RETAINED_2_DAY 领取七天礼包的第二天奖励时
606 + POOL_RETAINED_3_DAY 领取七天礼包的第三天奖励时
607 + POOL_RETAINED_7_DAY 领取七天礼包的第七天奖励时
608 +```
609 +
610 +
611 +代码示例:
612 +```
613 +充值成功类型例子:
614 +Map<String,Object> valueMap = new HashMap<>(); valueMap.put(PoolEventParameterName.POOL_ORDER_ID,System.currentTimeMillis()+"");//订单号
615 +valueMap.put(PoolEventParameterName.POOL_CURRENCY,"USD");//货币类型 USD:美元 CNY:人民币
616 +valueMap.put(PoolEventParameterName.POOL_PRICE,6);//充值金额
617 +PoolSdkHelper.trackEvent(getApplicationContext(),PoolEventType.POOL_PAY_SUCCESS,valueMap);
618 +
619 +其他类型例子:
620 +PoolSdkHelper.trackEvent(getApplicationContext(), PoolEventType.POOL_RES_LOADED,null);
621 +```
622 +
623 +
624 +# 3、自测用例 #
625 +### 3.1、接入环境下调用登录sdk会有默认测试账号进行登录,游戏会直接收到登录回调数据 ###
626 +
627 +- 成功收到登录回调,与服务端校验成功进入游戏
628 +
629 +![](http://i.imgur.com/tHxu8mx.png)
630 +
631 +### 3.2、游戏点击充值在接入环境下sdk会直接进行充值数据校验,点击充值后游戏可查看服务端是否收到充值结果通知 ###
632 +
633 +- 后台配置正确的游戏充值回调地址可以进行充值测试是否到账
634 +
635 +# 4、母包 #
636 +```
637 +4.1、接入公共 SDK 编译生成的 apk 即为打包工具使用的空白母包
638 +```
639 +
640 +
641 +# 5、单机无服务端时充值处理 #
642 +### 5.1、设置充值监听,登录接口前调用
643 +```java
644 +PoolSdkHelper.setPayListener(mPoolPayListener );
645 +```
646 +
647 +### 5.2、游戏发货成功时调用接口
648 +```java
649 +PoolSdkHelper.paymentSuccess(AppActivity.this, orderIds.toString());
650 +```
651 +
652 +代码示例:
653 +```java
654 +if(paramCustom == null || paramCustom.length() <= 0)
655 +{
656 +PoolSdkLog.logError("paysuccess data error :" + paramCustom);
657 +return;
658 +}
659 +
660 +try {
661 +PoolSdkLog.logInfo("paySuccess:" + paramCustom);
662 +JSONArray jsonArray = new JSONArray(paramCustom);
663 +StringBuilder orderIds = new StringBuilder();
664 +int length = jsonArray.length();
665 +for (int i = 0; i < length; i++) {
666 +JSONObject jb = jsonArray.getJSONObject(i);
667 +String orderId = jb.getString("orderId");
668 +orderIds.append(orderId);
669 +if(i != length -1) {//最后一项不加分割符
670 +orderIds.append(",");
671 +}
672 +}
673 +PoolSdkHelper.paymentSuccess(AppActivity.this, orderIds.toString());
674 +} catch (JSONException e) {
675 +// TODO Auto-generated catch block
676 +e.printStackTrace();
677 +}
678 +```
679 +
680 +# 6.游戏使用多dex打包需要注意的点
681 +1、如果游戏接入公共SDK后使用了多dex打包,请确保公共SDK保持在第一个classes.dex文件
682 +在defaultConfig中配置multiDexKeepProguard file('maindexlist.pro')
683 +```java
684 +-keep class com.gzyouai.fengniao.sdk.*
685 +-keep class com.gzyouai.fengniao.sdk.framework.*
686 +-keep class com.gzyouai.fengniao.sdk.wxapi.*
687 +-keep class com.gzyouai.publicsdk.application.*
688 +```
689 +2、如果母包需要每次出包Manifest中的配置改成相应的包名字段(例如推送和Provider)
690 +则将包名写成 originPackageTag 打包工具会自动替换成目标包名
691 +```xml
692 +android:authorities="com.xxx.provider"
693 +<!-- 写为下面这样既可 -->
694 +android:authorities="originPackageTag.provider"
695 +```
696 +
697 +# 7. 完整的接入demo
698 +```java
699 +import android.app.Activity;
700 +import android.app.AlertDialog;
701 +import android.content.DialogInterface;
702 +import android.content.Intent;
703 +import android.content.res.Configuration;
704 +import android.os.Bundle;
705 +import android.util.Log;
706 +import android.view.KeyEvent;
707 +import android.view.View;
708 +import android.view.WindowManager.LayoutParams;
709 +import android.widget.Button;
710 +import com.gzyouai.fengniao.sdk.framework.PoolExitDialogListener;
711 +import com.gzyouai.fengniao.sdk.framework.PoolExitListener;
712 +import com.gzyouai.fengniao.sdk.framework.PoolLoginInfo;
713 +import com.gzyouai.fengniao.sdk.framework.PoolLoginListener;
714 +import com.gzyouai.fengniao.sdk.framework.PoolLogoutListener;
715 +import com.gzyouai.fengniao.sdk.framework.PoolPayInfo;
716 +import com.gzyouai.fengniao.sdk.framework.PoolPayListener;
717 +import com.gzyouai.fengniao.sdk.framework.PoolRoleInfo;
718 +import com.gzyouai.fengniao.sdk.framework.PoolRoleListener;
719 +import com.gzyouai.fengniao.sdk.framework.PoolSDKCallBackListener;
720 +import com.gzyouai.fengniao.sdk.framework.PoolSDKCode;
721 +import com.gzyouai.fengniao.sdk.framework.PoolSdkConfig;
722 +import com.gzyouai.fengniao.sdk.framework.PoolSdkHelper;
723 +import com.gzyouai.fengniao.sdk.framework.PoolSdkLog;
724 +
725 +public class AppActivity extends Activity {
726 +
727 + private Button yaLoginBt;
728 + private Button yaEnterGameBt;
729 + private Button yaPayBt;
730 + private Button yaSubmitRoleDataBt;
731 + private Button yaChannelCenter;
732 + private Button yaLogoutBt;
733 + private Button yaForumBt;
734 + private Button yaSwitchAccountBt;
735 +
736 + @Override
737 + protected void onCreate(Bundle savedInstanceState) {
738 + super.onCreate(savedInstanceState);
739 + int layoutId = getResources().getIdentifier("public_sdk_self_game_login", "layout", getPackageName());
740 + setContentView(layoutId);
741 + initLoginView();
742 +
743 + //================================↓↓↓↓↓公共SDK接入代码示例↓↓↓↓↓==================================
744 +
745 + //PoolSdkHelper.isDebug = true;
746 + PoolSdkLog.setIsShowLog(true);
747 + PoolSdkHelper.init(this, new PoolSDKCallBackListener() {
748 + @Override
749 + public void poolSdkCallBack(int code, String msg) {
750 + // TODO Auto-generated method stub
751 + PoolSdkLog.logInfo("callback: code:" + code + "msg:" + msg);
752 + switch (code) {
753 + case PoolSDKCode.POOLSDK_INIT_SUCCESS:
754 + // 收到初始化成功回调才可以调用其他接口
755 + PoolSdkLog.logInfo("SDK初始化成功");
756 + login();
757 + break;
758 + case PoolSDKCode.POOLSDK_INIT_FAIL:
759 + break;
760 + default:
761 + break;
762 + }
763 + }
764 + });
765 +
766 + PoolSdkHelper.setLogoutCallback(new PoolLogoutListener() {
767 + @Override
768 + public void onLogoutSuccess() {
769 + //注销账号成功回调在这里通知,游戏收到注销成功,需自行回到登陆界面调用登陆接口
770 + PoolSdkLog.logInfo("游戏中logoutSuccess");
771 + login();
772 + }
773 + });
774 + }
775 +
776 + @Override
777 + public void onStart() {
778 + super.onStart();
779 + PoolSdkHelper.onStart();
780 + }
781 +
782 + @Override
783 + public void onStop() {
784 + super.onStop();
785 + PoolSdkHelper.onStop();
786 + }
787 +
788 + @Override
789 + public void onDestroy() {
790 + super.onDestroy();
791 + PoolSdkHelper.onDestroy();
792 + }
793 +
794 + @Override
795 + public void onResume() {
796 + super.onResume();
797 + PoolSdkHelper.onResume();
798 + }
799 +
800 + @Override
801 + public void onPause() {
802 + super.onPause();
803 + PoolSdkHelper.onPause();
804 +
805 + }
806 +
807 + @Override
808 + public void onRestart() {
809 + super.onRestart();
810 + PoolSdkHelper.onRestart();
811 + }
812 +
813 + @Override
814 + public void onNewIntent(Intent intent) {
815 + super.onNewIntent(intent);
816 + PoolSdkHelper.onNewIntent(intent);
817 + }
818 +
819 + @Override
820 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
821 + PoolSdkHelper.onActivityResult(requestCode, resultCode, data);
822 + }
823 +
824 + @Override
825 + public void onConfigurationChanged(Configuration newConfig) {
826 + // TODO Auto-generated method stub
827 + super.onConfigurationChanged(newConfig);
828 + PoolSdkHelper.onConfigurationChanged(newConfig);
829 + }
830 +
831 + @Override
832 + protected void onSaveInstanceState(Bundle outState) {
833 + // TODO Auto-generated method stub
834 + super.onSaveInstanceState(outState);
835 + PoolSdkHelper.onSaveInstanceState(outState);
836 + }
837 +
838 + @Override
839 + protected void onRestoreInstanceState(Bundle savedInstanceState) {
840 + // TODO Auto-generated method stub
841 + super.onRestoreInstanceState(savedInstanceState);
842 + PoolSdkHelper.onRestoreInstanceState(savedInstanceState);
843 + }
844 +
845 + @Override
846 + public void onWindowFocusChanged(boolean hasFocus) {
847 + // TODO Auto-generated method stub
848 + super.onWindowFocusChanged(hasFocus);
849 + PoolSdkHelper.onWindowFocusChanged(hasFocus);
850 + }
851 +
852 + @Override
853 + public void onWindowAttributesChanged(LayoutParams params) {
854 + // TODO Auto-generated method stub
855 + super.onWindowAttributesChanged(params);
856 + PoolSdkHelper.onWindowAttributesChanged(params);
857 + }
858 +
859 + @Override
860 + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
861 + // TODO Auto-generated method stub
862 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
863 + PoolSdkHelper.onRequestPermissionsResult(requestCode, permissions, grantResults);
864 + }
865 +
866 + //返回按钮退出游戏示例
867 + @Override
868 + public boolean dispatchKeyEvent(KeyEvent pKeyEvent) {
869 + if (pKeyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK&& pKeyEvent.getAction() == KeyEvent.ACTION_DOWN) {
870 +
871 + //点击返回,判断渠道SDK有无退出框
872 + if (PoolSdkHelper.hasExitDialog()) {
873 + PoolSdkHelper.showExitDialog(new PoolExitDialogListener() {
874 + @Override
875 + public void onDialogResult(int code, String msg) {
876 + switch (code) {
877 + case PoolSDKCode.EXIT_SUCCESS:// 退出成功游戏处理自己退出逻辑
878 + finish();
879 + break;
880 + case PoolSDKCode.EXIT_CANCEL:// 取消退出
881 + break;
882 + default:
883 + break;
884 + }
885 + }
886 + });
887 + } else {
888 + //没有则调用游戏的退出界面
889 + showGameExitTips();
890 + }
891 + return false;
892 + }
893 + return super.dispatchKeyEvent(pKeyEvent);
894 + }
895 +
896 +
897 + /**
898 + * 切换帐号/注销账号
899 + */
900 + private void switchAccount() {
901 + //游戏请先调用 PoolSdkHelper.hasLogout() PoolSdkHelper.hasSwitchAccount() 接口 判断渠道SDK有没有该接口
902 +
903 + if(PoolSdkHelper.hasLogout()){
904 + //如果渠道SDK有注销接口,那么游戏可以添加注销按钮,实现 PoolSdkHelper.logout(this); 结果在注销监听回调中处理
905 + PoolSdkHelper.logout(this);
906 +
907 + }else if(PoolSdkHelper.hasSwitchAccount()){
908 + //如果渠道SDK有切换账号接口,那么游戏可以添加切换账号按钮,实现 PoolSdkHelper.switchAccount(this); 新账号结果在登陆回调中处理
909 + PoolSdkHelper.switchAccount(this);
910 + }else{
911 + //直接回到登录界面调用登录
912 + int layoutId = getResources().getIdentifier("public_sdk_self_game_login", "layout", getPackageName());
913 + setContentView(layoutId);
914 + initLoginView();
915 + }
916 + }
917 +
918 + private void openForum(){
919 + PoolSdkHelper.openForum();
920 + }
921 +
922 + //单独注销按钮 注销账号
923 + private void logout(){
924 + if(PoolSdkHelper.hasLogout()){
925 + PoolSdkHelper.logout(this);//结果回调通知到PoolLogoutListener
926 + }
927 + }
928 +
929 + private void login() {
930 +
931 + PoolSdkHelper.login("登录自定义字段", new PoolLoginListener() {
932 + @Override
933 + public void onLoginSuccess(PoolLoginInfo poolLoginInfo) {
934 + String userType = poolLoginInfo.getUserType();
935 + String timestamp = poolLoginInfo.getTimestamp();
936 + String serverSign = poolLoginInfo.getServerSign();
937 + String openId = poolLoginInfo.getOpenID();
938 + // TODO: 把以上信息发送给游戏服务端做登录校验,需要其他信息请从poolLoginInfo对象中获取
939 +
940 + System.out.println("登录成功 userType = " + userType + "; timestamp = " + timestamp + "; serverSign = " + serverSign + "; openId = " + openId);
941 + }
942 +
943 + @Override
944 + public void onLoginFailed(String errorMsg) {
945 + System.out.println("登录失败 = " + errorMsg);
946 + }
947 + });
948 + }
949 +
950 + private void pay() {
951 + final PoolPayInfo poolPayInfo = new PoolPayInfo();
952 +
953 + /********************************************
954 + * 以下所有字段都是必填项
955 + */
956 + // 设置充值金额,单位“元”
957 + poolPayInfo.setAmount("1");
958 + // 服务器id
959 + poolPayInfo.setServerID("8");
960 + // 服务器名
961 + poolPayInfo.setServerName("我是服务器名");
962 + // 角色id
963 + poolPayInfo.setRoleID("123456");
964 + // 角色名
965 + poolPayInfo.setRoleName("我是角色名");
966 + // 角色等级
967 + poolPayInfo.setRoleLevel("10");
968 + // 商品ID
969 + poolPayInfo.setProductID("1");
970 + // 商品名称
971 + poolPayInfo.setProductName("金币");
972 + // 商品描述
973 + poolPayInfo.setProductDesc("购买金币");
974 + // 兑换比例
975 + poolPayInfo.setExchange("10");
976 + // 自定义参数
977 + poolPayInfo.setCustom("operator=xwrw&server_id=39&player_id=2081&cp_order_id=001000100000020811491470345294&dext=2");
978 +
979 + // TODO Auto-generated method stub
980 + PoolSdkHelper.pay(poolPayInfo, new PoolPayListener() {
981 +
982 + @Override
983 + public void onPaySuccess(String paramCustom) {
984 + System.out.println("支付成功 = " + paramCustom);
985 + }
986 +
987 + @Override
988 + public void onPayFailed(String paramCustom, String errorMsg) {
989 + System.out.println("支付失败 = " + paramCustom + "; errorMsg = "
990 + + errorMsg);
991 + }
992 + });
993 +
994 + }
995 +
996 + /**
997 + * 提交角色数据 该接口需要在3个地方调用
998 + *
999 + * 1、登录游戏主场景 2、创建角色 3、角色升级
1000 + */
1001 + private void submitRoleData() {
1002 + /********************************************
1003 + * 以下所有字段都是必填项
1004 + */
1005 + PoolRoleInfo poolRoleInfo = new PoolRoleInfo();
1006 + poolRoleInfo.setRoleID("123456");
1007 + poolRoleInfo.setRoleLevel("10");
1008 + poolRoleInfo.setRoleSex("0");
1009 + poolRoleInfo.setRoleName("我是角色名");
1010 + poolRoleInfo.setServerID("8");
1011 + poolRoleInfo.setServerName("我是服务器名");
1012 + poolRoleInfo.setCustom("角色创建时间");
1013 + poolRoleInfo.setRoleCTime(System.currentTimeMillis()/1000);//角色创建时间(秒)
1014 + poolRoleInfo.setPartyName("公会名称");
1015 + poolRoleInfo.setRoleType("狂战");//角色类型
1016 + poolRoleInfo.setRoleChangeTime(System.currentTimeMillis()/1000);//角色更新时间
1017 + poolRoleInfo.setVipLevel("10");//vip等级
1018 + poolRoleInfo.setDiamond("1000");//余额
1019 + poolRoleInfo.setMoneyType("金币");//商品单位
1020 +
1021 + poolRoleInfo.setCallType(PoolRoleInfo.Type_EnterGame);
1022 + // poolRoleInfo.setCallType(PoolRoleInfo.Type_CreateRole);
1023 + // poolRoleInfo.setCallType(PoolRoleInfo.Type_RoleUpgrade);
1024 +
1025 + PoolSdkHelper.submitRoleData(poolRoleInfo, new PoolRoleListener() {
1026 + @Override
1027 + public void onRoleDataSuccess(String paramCustom) {
1028 + System.out.println("提交角色数据成功 = " + paramCustom);
1029 + }
1030 + });
1031 + }
1032 +
1033 + /**
1034 + * 用户中心
1035 + *
1036 + * 游戏方先调用PoolSdkHelper.hasChannelCenter()获取是否有用户中心,
1037 + * 如果有的话,游戏中需要添加按钮,点击按钮调用PoolSdkHelper.openChannelCenter();
1038 + * 如果没有,则不需要显示按钮,也不用调用下面的接口
1039 + */
1040 + private void channelCenter() {
1041 + PoolSdkHelper.openChannelCenter();
1042 + }
1043 +
1044 + //================================↑↑↑↑↑公共SDK接入代码示例↑↑↑↑↑==================================
1045 +
1046 + private void showGameExitTips() {
1047 + AlertDialog.Builder dialog = new AlertDialog.Builder(this);
1048 + int ic_dialog_alert_id = getRedIdByName("ic_dialog_alert", "drawable");
1049 + dialog.setIcon(ic_dialog_alert_id);
1050 + dialog.setTitle("提示");
1051 + dialog.setMessage("是否退出游戏?");
1052 + dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
1053 + @Override
1054 + public void onClick(DialogInterface dialog, int which) {
1055 + PoolSdkHelper.exitGame(new PoolExitListener() {
1056 + @Override
1057 + public void onExitGame() {
1058 + finish();
1059 + }
1060 + });
1061 + }
1062 + });
1063 + dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
1064 + @Override
1065 + public void onClick(DialogInterface dialog, int which) {
1066 + dialog.dismiss();
1067 + }
1068 + });
1069 + dialog.show();
1070 + }
1071 +
1072 + private int getRedIdByName(String resName, String resType) {
1073 + return getResources().getIdentifier(resName, resType, getPackageName());
1074 + }
1075 +
1076 + private void initLoginView() {
1077 + int ya_login_bt = getRedIdByName("ya_login_bt", "id");// getResources().getIdentifier("ya_login_bt",
1078 + // "id",
1079 + // getPackageName());
1080 + yaLoginBt = (Button) findViewById(ya_login_bt);
1081 + yaLoginBt.setText("登录");
1082 + yaEnterGameBt = (Button) findViewById(getRedIdByName(
1083 + "ya_enter_game_bt", "id"));
1084 + yaEnterGameBt.setText("进入游戏");
1085 + }
1086 +
1087 + private void initGameView() {
1088 + yaPayBt = (Button) findViewById(getRedIdByName("ya_pay_bt", "id"));
1089 + yaPayBt.setText("支付");
1090 + yaSubmitRoleDataBt = (Button) findViewById(getRedIdByName(
1091 + "ya_submit_role_data_bt", "id"));
1092 + yaSubmitRoleDataBt.setText("提交角色数据");
1093 + yaChannelCenter = (Button) findViewById(getRedIdByName(
1094 + "ya_channel_center", "id"));
1095 + yaChannelCenter.setText("渠道中心");
1096 + PoolSdkLog.logError("" + yaPayBt + "yachannel:" + yaChannelCenter);
1097 +
1098 + yaLogoutBt = (Button) findViewById(getRedIdByName("logout_bt", "id"));
1099 +
1100 + yaSwitchAccountBt = (Button) findViewById(getRedIdByName("ya_switch_account_bt", "id"));
1101 + yaSwitchAccountBt.setText("切换账号");
1102 +
1103 + yaForumBt = (Button) findViewById(getRedIdByName("forum_bt", "id"));
1104 + }
1105 +
1106 + public void yaOnClick(View view) {
1107 + if (view == yaLoginBt) {
1108 + login();
1109 + } else if (view == yaEnterGameBt) {
1110 + setContentView(getRedIdByName("public_sdk_self_game", "layout"));// (R.layout.game);
1111 + //模拟调用聊天接口:
1112 + //PoolSdkHelper.reportChat("content", "世界", "roleId", "roleName", 10, "serverId", "serverName");
1113 +
1114 + initGameView();
1115 + } else if (view == yaPayBt) {
1116 + pay();
1117 + } else if (view == yaSubmitRoleDataBt) {
1118 + submitRoleData();
1119 + } else if (view == yaChannelCenter) {
1120 + channelCenter();
1121 + } else if (view == yaLogoutBt){
1122 + logout();
1123 + } else if (view == yaForumBt){
1124 + openForum();
1125 + } else if(view == yaSwitchAccountBt){//切换账号
1126 + switchAccount();
1127 + }
1128 + }
1129 +}
1130 +
1131 +```
...\ No newline at end of file ...\ No newline at end of file
1 +# 公共SDK服务端接入文档
2 +
3 +### 1.登录验证
4 + 客户端发送请求参数给服务端,服务端对参数进行 MD5 加密,如果加密结果和serverSign 一致,则验证通过,否则不通过
5 +参数 | 类型 | 描述
6 +------------ | ------------- | ------------
7 +userType | int | 用户类型 ID(渠道类型,兼容以 前帐号体系)
8 +openId | string | 平台渠道方返回用户ID
9 +timestamp | string | 时间戳,公共SDK发送到客户端的参数timestamp, 服务端可以判断 timestamp 是否 在有效的登录时间内
10 +serverSign | string | 验证密钥,公共 SDK 发送到 客户端的参数 serverSign,加密串:gameAppkey=%s&userType=% s&openId=%s&timestamp=%s注意:(改为游戏本身的gameAppkey值)
11 +
12 +验证方式:
13 +serverSign=MD5(gameAppkey=%s&userType=%s&openId=%s&timestamp=%s) 如:
14 +md5("gameAppkey=xxxx&userType=1&openId=123&timestamp=111111111111")
15 +gameAppkey : 在公共SDK后台的 Md5加密的KEY
16 +
17 +`注意!CP必须要以userType+openId保证帐号唯一性`
18 +
19 +### 2. 充值验证(通知游戏方发货)
20 + 公共SDK服务器接收到渠道服务器充值回调,对回调进行 MD5 验证,如果验证通过, 则采用Post方式马上回调给游戏充值服务器,否则不会回调充值服务器,然后再返回 信息给渠道服务器。回调参数如下:
21 +参数 | 类型 | 描述
22 +------------ | -------------| ------------
23 +serverId | int | 服务器 ID
24 +playerId | int | 角色 ID
25 +orderId | string | 渠道方订单 ID
26 +payAmount | double | 充值金额(如有商品 ID,此值为商 品的金额, 单位元)
27 +currency | string | 充值货币(CNY:人民币)
28 +goodsId | string | 商品ID,参数对一些有商品列表 的充值有效
29 +goodsName | string | 商品名称
30 +remoteIp | string | 客户端充值 IP
31 +custom | string | 透传参数 ,长度 512
32 +serverSign | string | 发给充值服务器验证的注意:(改为游戏本身的 gameAppkey 值)
33 +uId | string | 平台渠道帐号 ID
34 +gameSimpleName | string | 平台SDK后台游戏代号名
35 +sdkSimpleName | string | 平台SDK代号
36 +queryId | string | 平台SDK订单号
37 +postTime | string | 订单创建时间戳
38 +sign | string | 升级Md5加密的值
39 +验证方式:
40 +旧:serverSign=MD5(serverId=%s&playerId=%s&orderId=%s&gameAppKey=%s)
41 +升级:sign=Md5('serverId=%s&playerId=%s&orderId=%s&payAmount=%s&goodsId=%s&sdkSimpleName=%s&gameAppKey=%s')
42 +%s:为相应的值
43 +gameAppkey : 在公共SDK后台的Md5加密的KEY
44 +验证通过后,返回公共 SDK 服务器数据,数据格式:{"code":0,"message":"无订 单"}。code:0 表示失败,1 表示成功,message:描述原因。
45 +
46 +`注意!CP必须要以orderId+sdkSimpleName保证订单唯一性,建议使用sign验证`
47 +
48 +### 3. 充值服务器IP地址
49 + 182.254.136.76
50 + 115.159.41.44
51 + 115.159.109.183
52 + 118.89.113.235
53 + 118.89.196.17
...\ No newline at end of file ...\ No newline at end of file
1 +
2 +## 1.魅族 ##
3 +
4 +### 调试登录时,提示“游戏不存在”或“游戏签名不正确” ###
5 +
6 +SDK 服务端会对参数作必要的校验,校验不通过则有此提示
7 +
8 +1、联系运营检查该游戏是否打开了联调状态
9 +
10 +2、联系运营检查是否创建了该游戏
11 +
12 +3、上架后的游戏需要从游戏中心下载 APK 包进行安装
13 +
14 +## 2.搜狗 ##
15 +
16 +### 参数QQ_APPID要自行到QQ开放平台申请手Q ID ###
17 +
18 +签名必须跟应用宝YSDK一致
19 +
20 +## 3.华为 ##
21 +
22 +### 需要母包删除 libs 中的 YouaiSDK.jar 再打包 ###
23 +
24 +## 4.三星 ##
25 +
26 +### 参数 waresid 为商品ID,需去三星后台设置为应用传入价格 ###
27 +
28 +## 5.联想 ##
29 +
30 +### waresid请到联想后台申请商品编码(使用开放价格模式) ###
31 +
32 +
33 +## 6.UC ##
34 +
35 +### 提交角色信息接口 ###
36 +
37 +PoolSdkHelper.submitRoleData接口中的角色创建时间和角色等级变化时间需传正确的值,否则不过审
38 +
39 +poolRoleInfo.setRoleChangeTime();//角色等级变化时间
40 +
41 +poolRoleInfo.setRoleCTime();//角色创建时间
42 +
43 +## 7.酷派 ##
44 +
45 +### platPublicKey平台公钥默认值 ###
46 +
47 +```
48 +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLx50R+CpH6VD/EfavOTpHOydfAQVjvm/h/SGG/RbM/03ZDfk8JrgezyFwqX06pjKevHZz66Umoq1/3Z9oqhBlJezsM03q2woKbReGSKAPQSkuJg2FY6DdZ1v1gMuCRtF6WOHV7n2TbUvRhZugMpx8PJEV+r6Qf1L41Gt8w6FN8wIDAQAB
49 +```
50 +
51 +如渠道有提供以提供为准,没有填默认值
52 +
53 +## 8.应用宝YSDK ##
54 +
55 +### 请保留好在应用宝后台申请时使用的签名文件,打包时需使用一致的 ###
56 +
57 +
58 +## 9.OPPO ##
59 +
60 +### publicKey应用公钥 ###
61 +
62 +```
63 +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCmreYIkPwVovKR8rLHWlFVw7YDfm9uQOJKL89Smt6ypXGVdrAKKl0wNYc3/jecAoPi2ylChfa2iRu5gunJyNmpWZzlCNRIau55fxGW0XEu553IiprOZcaw5OuYGlf60ga8QT6qToP0/dpiL/ZbmNUO9kUhosIjEu22uFgR+5cYyQIDAQAB
64 +```
65 +
66 +如渠道有提供以提供为准,没有填默认值
67 +
68 +## 10.HTC ##
69 +
70 +### joloPrivateKey私钥 ###
71 +
72 +- "HTC秘钥生成工具与文档"
73 +
74 +[https://pan.baidu.com/s/1dE7FSm1](https://pan.baidu.com/s/1dE7FSm1 "HTC秘钥生成工具与文档")
75 +
76 +强烈建议找渠道技术帮忙生成
77 +
78 +
79 +## 11.卓易 ##
80 +
81 +### 1.注册账号时输入的账号密码文字颜色和输入框底色相同 ###
82 +<Application>的theme改成android:theme="@android:style/Theme.Black.NoTitleBar"
83 +
84 +或者把Activity的theme改成android:theme="@android:style/Theme.Black.NoTitleBar"
85 +
86 +
87 +### 2.集成到游戏后,发现卓易悬浮图标点击没反应 ###
88 +
89 +如果是Unity3D的游戏的话,由于Unity3D和Android之间的事件冲突,导致Android事件得不到响应。
90 +
91 +解决办法是,需要将游戏的主Activity(游戏入口)默认继承的NativeActivity或UnityPlayerNativeActivity改为继承Activity,把UnityPlayerNativeActivity里面的方法(如下图所示)拷贝到主Activity。
92 +
93 +现在最新Unity3D版本游戏入口也是默认继承Activity。
94 +
95 +![](http://i.imgur.com/SlVKWAp.png)
96 +
97 +## 12.打包 ##
98 +
99 +参数提前确定准备好,尤其是icon,闪图那些
100 +
101 +填写某渠道参数时,请牢记到对应渠道后台填写充值回调地址
102 +
103 +
104 +## 13.多玩YY ##
105 +
106 +### 支付时显示支付未成功,appid不存在 ###
107 +
108 +因为签名不正确,在游戏提交后联运管理台后,会重新打包签名。(如不了解请与渠道联系)
109 +
110 +## 14.360 ##
111 +
112 +### 支付时显示Mobile pay signature invalid ###
113 +
114 +后台填写的 QHOPENSDK_PRIVATEKEY 参数错误导致,注意此处 private_key,不是app_secret,其生成算法为 app_secret +”#”+ app_key 的加密MD5值,结果为32位全小写(http://pmd5.com/ 在线计算MD5)
115 +
116 +![](https://i.imgur.com/JrsLmBZ.png)
117 +
118 +如图,替换自己的 app_secret 和 app_key 即可
...\ No newline at end of file ...\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type