lizhihui

update demo

1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="CompilerConfiguration">
4 + <bytecodeTargetLevel target="1.8" />
5 + </component>
6 +</project>
...\ No newline at end of file ...\ No newline at end of file
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
14 </set> 14 </set>
15 </option> 15 </option>
16 <option name="resolveModulePerSourceSet" value="false" /> 16 <option name="resolveModulePerSourceSet" value="false" />
17 + <option name="useQualifiedModuleNames" value="true" />
17 </GradleProjectSettings> 18 </GradleProjectSettings>
18 </option> 19 </option>
19 </component> 20 </component>
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="RemoteRepositoriesConfiguration">
4 + <remote-repository>
5 + <option name="id" value="central" />
6 + <option name="name" value="Maven Central repository" />
7 + <option name="url" value="https://repo1.maven.org/maven2" />
8 + </remote-repository>
9 + <remote-repository>
10 + <option name="id" value="jboss.community" />
11 + <option name="name" value="JBoss Community repository" />
12 + <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
13 + </remote-repository>
14 + <remote-repository>
15 + <option name="id" value="BintrayJCenter" />
16 + <option name="name" value="BintrayJCenter" />
17 + <option name="url" value="https://jcenter.bintray.com/" />
18 + </remote-repository>
19 + <remote-repository>
20 + <option name="id" value="Google" />
21 + <option name="name" value="Google" />
22 + <option name="url" value="https://dl.google.com/dl/android/maven2/" />
23 + </remote-repository>
24 + <remote-repository>
25 + <option name="id" value="D:\AndroidSDK\extras\m2repository" />
26 + <option name="name" value="D:\AndroidSDK\extras\m2repository" />
27 + <option name="url" value="file:/$PROJECT_DIR$/../../../AndroidSDK/extras/m2repository" />
28 + </remote-repository>
29 + <remote-repository>
30 + <option name="id" value="D:\AndroidSDK\extras\google\m2repository" />
31 + <option name="name" value="D:\AndroidSDK\extras\google\m2repository" />
32 + <option name="url" value="file:/$PROJECT_DIR$/../../../AndroidSDK/extras/google/m2repository" />
33 + </remote-repository>
34 + <remote-repository>
35 + <option name="id" value="D:\AndroidSDK\extras\android\m2repository" />
36 + <option name="name" value="D:\AndroidSDK\extras\android\m2repository" />
37 + <option name="url" value="file:/$PROJECT_DIR$/../../../AndroidSDK/extras/android/m2repository" />
38 + </remote-repository>
39 + </component>
40 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> 3 + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
4 <output url="file://$PROJECT_DIR$/build/classes" /> 4 <output url="file://$PROJECT_DIR$/build/classes" />
5 </component> 5 </component>
6 <component name="ProjectType"> 6 <component name="ProjectType">
......
1 apply plugin: 'com.android.application' 1 apply plugin: 'com.android.application'
2 2
3 android { 3 android {
4 - compileSdkVersion 28 4 + compileSdkVersion 29
5 buildToolsVersion '29.0.2' 5 buildToolsVersion '29.0.2'
6 defaultConfig { 6 defaultConfig {
7 - applicationId "com.ssjh.demo" 7 + applicationId "com.poolsdk.demo"
8 - minSdkVersion 14 8 + minSdkVersion 21
9 - targetSdkVersion 28 9 + targetSdkVersion 29
10 versionCode 2 10 versionCode 2
11 versionName "1.0" 11 versionName "1.0"
12 } 12 }
...@@ -32,6 +32,6 @@ dependencies { ...@@ -32,6 +32,6 @@ dependencies {
32 // implementation 'com.android.installreferrer:installreferrer:1.0' 32 // implementation 'com.android.installreferrer:installreferrer:1.0'
33 33
34 // implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0' 34 // implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'
35 - compile 'com.google.firebase:firebase-core:16.0.6' 35 +// compile 'com.google.firebase:firebase-core:16.0.6'
36 - compile 'com.google.firebase:firebase-messaging:17.3.4' 36 +// compile 'com.google.firebase:firebase-messaging:17.3.4'
37 } 37 }
......
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 - package="com.youai.demo.shenshou"> 3 + package="com.poolsdk.demo">
4 4
5 <!-- SDK start --> 5 <!-- SDK start -->
6 - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
7 <uses-permission android:name="android.permission.INTERNET" /> 6 <uses-permission android:name="android.permission.INTERNET" />
8 - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 7 + <!-- 国内需要用公共SDK的后台数据功能需要以下权限 -->
9 <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 8 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
10 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 9 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
11 - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 10 + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
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 --> 11 <!-- SDK end -->
17 12
18 <application 13 <application
19 android:name="com.gzpublic.app.sdk.application.PoolSDKApplication" 14 android:name="com.gzpublic.app.sdk.application.PoolSDKApplication"
20 android:allowBackup="false" 15 android:allowBackup="false"
21 android:icon="@drawable/public_sdk_self_ic_launcher" 16 android:icon="@drawable/public_sdk_self_ic_launcher"
22 - android:label="@string/app_name" > 17 + android:label="@string/app_name">
23 <activity 18 <activity
24 android:name="com.youai.foolsdk.demo.AppActivity" 19 android:name="com.youai.foolsdk.demo.AppActivity"
25 android:configChanges="keyboardHidden|orientation|screenSize" 20 android:configChanges="keyboardHidden|orientation|screenSize"
26 android:label="@string/app_name" 21 android:label="@string/app_name"
27 android:screenOrientation="portrait" 22 android:screenOrientation="portrait"
28 - android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > 23 + android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
29 <intent-filter> 24 <intent-filter>
30 <action android:name="android.intent.action.MAIN" /> 25 <action android:name="android.intent.action.MAIN" />
31 26
32 <category android:name="android.intent.category.LAUNCHER" /> 27 <category android:name="android.intent.category.LAUNCHER" />
33 </intent-filter> 28 </intent-filter>
34 </activity> 29 </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 30
54 - <category android:name="android.intent.category.LAUNCHER" /> 31 + <!-- SDK start -->
55 - </intent-filter>
56 - </receiver>
57 32
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 --> 33 <!-- SDK end -->
69 </application> 34 </application>
70 35
......
...@@ -3,21 +3,18 @@ package com.youai.foolsdk.demo; ...@@ -3,21 +3,18 @@ package com.youai.foolsdk.demo;
3 import android.Manifest; 3 import android.Manifest;
4 import android.app.Activity; 4 import android.app.Activity;
5 import android.app.AlertDialog; 5 import android.app.AlertDialog;
6 -import android.app.Application;
7 import android.content.DialogInterface; 6 import android.content.DialogInterface;
8 import android.content.Intent; 7 import android.content.Intent;
9 import android.content.res.Configuration; 8 import android.content.res.Configuration;
10 import android.os.Build; 9 import android.os.Build;
11 import android.os.Bundle; 10 import android.os.Bundle;
12 import android.os.Handler; 11 import android.os.Handler;
13 -import android.util.Log;
14 import android.view.KeyEvent; 12 import android.view.KeyEvent;
15 import android.view.View; 13 import android.view.View;
16 import android.view.View.OnClickListener; 14 import android.view.View.OnClickListener;
17 import android.view.WindowManager.LayoutParams; 15 import android.view.WindowManager.LayoutParams;
18 import android.widget.Button; 16 import android.widget.Button;
19 import android.widget.TextView; 17 import android.widget.TextView;
20 -import android.widget.Toast;
21 18
22 import com.gzpublic.app.sdk.framework.PoolEventParameterName; 19 import com.gzpublic.app.sdk.framework.PoolEventParameterName;
23 import com.gzpublic.app.sdk.framework.PoolEventType; 20 import com.gzpublic.app.sdk.framework.PoolEventType;
...@@ -30,7 +27,6 @@ import com.gzpublic.app.sdk.framework.PoolLogoutListener; ...@@ -30,7 +27,6 @@ import com.gzpublic.app.sdk.framework.PoolLogoutListener;
30 import com.gzpublic.app.sdk.framework.PoolPayInfo; 27 import com.gzpublic.app.sdk.framework.PoolPayInfo;
31 import com.gzpublic.app.sdk.framework.PoolPayListener; 28 import com.gzpublic.app.sdk.framework.PoolPayListener;
32 import com.gzpublic.app.sdk.framework.PoolPayOrderConfirmHandler; 29 import com.gzpublic.app.sdk.framework.PoolPayOrderConfirmHandler;
33 -import com.gzpublic.app.sdk.framework.PoolReport;
34 import com.gzpublic.app.sdk.framework.PoolRoleInfo; 30 import com.gzpublic.app.sdk.framework.PoolRoleInfo;
35 import com.gzpublic.app.sdk.framework.PoolRoleListener; 31 import com.gzpublic.app.sdk.framework.PoolRoleListener;
36 import com.gzpublic.app.sdk.framework.PoolSDKCallBackListener; 32 import com.gzpublic.app.sdk.framework.PoolSDKCallBackListener;
...@@ -45,31 +41,18 @@ import org.json.JSONException; ...@@ -45,31 +41,18 @@ import org.json.JSONException;
45 import org.json.JSONObject; 41 import org.json.JSONObject;
46 42
47 import java.util.HashMap; 43 import java.util.HashMap;
48 -import java.util.Locale;
49 import java.util.Map; 44 import java.util.Map;
50 45
51 public class AppActivity extends Activity implements OnClickListener { 46 public class AppActivity extends Activity implements OnClickListener {
52 - //新的view
53 - private Button btLogin;
54 - private Button btEnterGame;
55 - private Button btPay;
56 - private Button btLogout;
57 - private Button btSubRoleInfo;
58 - private Button btOpenChannel;
59 - private Button btSwitchAcc;
60 - private Button btOpenBbs;
61 - private Button btQueryProducts;
62 - private Button pb_bt_verifyname;
63 47
64 - private Bundle saveBundle;
65 - //提示LOG
66 - private TextView txMsg,txSdkMsg;
67 - private Activity mContext;
68 - private PoolPayListener mPoolPayListener = new PoolPayListener() {
69 48
49 + private PoolPayListener mPoolPayListener = new PoolPayListener() {
70 @Override 50 @Override
71 - public void onPaySuccess(String paramCustom) {//支付回调以服务端通知为准 51 + public void onPaySuccess(String paramCustom) {
72 - // TODO Auto-generated method stub 52 + //支付回调以服务端通知为准
53 + upTx("支付成功回调:" + paramCustom);
54 +
55 +
73 //[{"orderId":"20180116114151740535D825","state":0,"productId":"1","productName":"金币","amout":0}] 56 //[{"orderId":"20180116114151740535D825","state":0,"productId":"1","productName":"金币","amout":0}]
74 if(paramCustom == null || paramCustom.length() <= 0) 57 if(paramCustom == null || paramCustom.length() <= 0)
75 { 58 {
...@@ -94,22 +77,19 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -94,22 +77,19 @@ public class AppActivity extends Activity implements OnClickListener {
94 // TODO Auto-generated catch block 77 // TODO Auto-generated catch block
95 e.printStackTrace(); 78 e.printStackTrace();
96 } 79 }
97 - upTx("支付成功回调:" + paramCustom);
98 } 80 }
99 81
100 @Override 82 @Override
101 public void onPayFailed(String paramCustom, String errorMsg) { 83 public void onPayFailed(String paramCustom, String errorMsg) {
102 - // TODO Auto-generated method stub 84 + System.out.println("支付失败回调:" + paramCustom + "; errorMsg:"+ errorMsg);
103 - System.out.println("支付失败回调:" + paramCustom + "; errorMsg:" 85 + upTx("支付失败回调:" + paramCustom + "; errorMsg:" + errorMsg);
104 - + errorMsg);
105 - upTx("支付失败回调:" + paramCustom + "; errorMsg:"
106 - + errorMsg);
107 } 86 }
108 }; 87 };
109 88
110 @Override 89 @Override
111 public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { 90 public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
112 super.onRequestPermissionsResult(requestCode, permissions, grantResults); 91 super.onRequestPermissionsResult(requestCode, permissions, grantResults);
92 +
113 PoolSdkHelper.onRequestPermissionsResult(requestCode, permissions, grantResults); 93 PoolSdkHelper.onRequestPermissionsResult(requestCode, permissions, grantResults);
114 init(saveBundle); 94 init(saveBundle);
115 } 95 }
...@@ -118,17 +98,17 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -118,17 +98,17 @@ public class AppActivity extends Activity implements OnClickListener {
118 protected void onCreate(Bundle savedInstanceState) { 98 protected void onCreate(Bundle savedInstanceState) {
119 super.onCreate(savedInstanceState); 99 super.onCreate(savedInstanceState);
120 saveBundle = savedInstanceState; 100 saveBundle = savedInstanceState;
121 - int layoutId = getResources().getIdentifier(
122 - "public_sdk_self_test", "layout", getPackageName());
123 - setContentView(layoutId);
124 - mContext = this;
125 initView(); 101 initView();
102 +
103 +
126 PoolSdkLog.setIsShowLog(true); 104 PoolSdkLog.setIsShowLog(true);
127 PoolSdkConfig.readPoolSdkConfigData(this); 105 PoolSdkConfig.readPoolSdkConfigData(this);
128 106
107 + //国内游戏接入如果需要使用平台统计等功能,需要获取手机识别号和读写SD卡权限再调用初始化接口
129 if(getApplicationInfo().targetSdkVersion >= 23 && Build.VERSION.SDK_INT >= 23){ 108 if(getApplicationInfo().targetSdkVersion >= 23 && Build.VERSION.SDK_INT >= 23){
130 requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE,Manifest.permission.WRITE_EXTERNAL_STORAGE},1); 109 requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE,Manifest.permission.WRITE_EXTERNAL_STORAGE},1);
131 - }else {//不需要权限直接调用init 110 + }else {
111 + //不需要权限直接调用init
132 this.init(savedInstanceState); 112 this.init(savedInstanceState);
133 } 113 }
134 114
...@@ -140,16 +120,18 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -140,16 +120,18 @@ public class AppActivity extends Activity implements OnClickListener {
140 } 120 }
141 121
142 private void init( Bundle savedInstanceState){ 122 private void init( Bundle savedInstanceState){
123 +
124 + //PoolSDK初始化接口
143 PoolSdkHelper.init(this, new PoolSDKCallBackListener() { 125 PoolSdkHelper.init(this, new PoolSDKCallBackListener() {
144 @Override 126 @Override
145 public void poolSdkCallBack(int code, String msg) { 127 public void poolSdkCallBack(int code, String msg) {
146 PoolSdkLog.logInfo("poolSdkCallBack:code:" + code + ",msg:" + msg); 128 PoolSdkLog.logInfo("poolSdkCallBack:code:" + code + ",msg:" + msg);
147 upTx("poolSdkCallBack:code:" + code + ",msg:" + msg); 129 upTx("poolSdkCallBack:code:" + code + ",msg:" + msg);
148 switch (code) { 130 switch (code) {
149 - case PoolSDKCode.POOLSDK_INIT_SUCCESS:// 初始化成功 131 + case PoolSDKCode.POOLSDK_INIT_SUCCESS:
132 + // 初始化成功,游戏可以调用登录接口
150 PoolSdkLog.logInfo("游戏中收到初始化成功回调"); 133 PoolSdkLog.logInfo("游戏中收到初始化成功回调");
151 new Handler().postDelayed(new Runnable() { 134 new Handler().postDelayed(new Runnable() {
152 -
153 @Override 135 @Override
154 public void run() { 136 public void run() {
155 login(); 137 login();
...@@ -157,8 +139,10 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -157,8 +139,10 @@ public class AppActivity extends Activity implements OnClickListener {
157 }, 1000); 139 }, 1000);
158 break; 140 break;
159 case PoolSDKCode.POOLSDK_INIT_FAIL: 141 case PoolSDKCode.POOLSDK_INIT_FAIL:
142 + //初始化失败,游戏可以尝试重新调用初始化接口或退出游戏等操作
160 break; 143 break;
161 case PoolSDKCode.POOLSDK_QUERY_WITH_PRODUCTS: 144 case PoolSDKCode.POOLSDK_QUERY_WITH_PRODUCTS:
145 + //该接口为查询谷歌支付当地货币价格接口,国内游戏无需接入
162 //msg:为查询的结果值 146 //msg:为查询的结果值
163 /** 147 /**
164 * {//查询商品信息返回数据 148 * {//查询商品信息返回数据
...@@ -173,7 +157,8 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -173,7 +157,8 @@ public class AppActivity extends Activity implements OnClickListener {
173 * } 157 * }
174 */ 158 */
175 break; 159 break;
176 - case PoolSDKCode.POOLSDK_EXTENDS_CODE1://实名认证成功才有回调 160 + case PoolSDKCode.POOLSDK_EXTENDS_CODE1:
161 + //实名认证成功才有回调
177 //msg为生日 162 //msg为生日
178 break; 163 break;
179 164
...@@ -195,18 +180,22 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -195,18 +180,22 @@ public class AppActivity extends Activity implements OnClickListener {
195 } 180 }
196 } 181 }
197 },savedInstanceState);// init(this);// this为游戏的activity对象 182 },savedInstanceState);// init(this);// this为游戏的activity对象
183 +
184 + //设置支付回调接口监听
198 PoolSdkHelper.setPayListener(mPoolPayListener); 185 PoolSdkHelper.setPayListener(mPoolPayListener);
186 +
187 + //设置注销账号接口监听
199 PoolSdkHelper.setLogoutCallback(new PoolLogoutListener() { 188 PoolSdkHelper.setLogoutCallback(new PoolLogoutListener() {
200 @Override 189 @Override
201 public void onLogoutSuccess() { 190 public void onLogoutSuccess() {
202 // TODO: 此处处理SDK登出的逻辑 191 // TODO: 此处处理SDK登出的逻辑
203 - PoolSdkLog.logInfo("游戏中收到logoutSuccess回调"); 192 + PoolSdkLog.logInfo("游戏中收到SDK logoutSuccess回调");
193 + //游戏退出当前账号 回到初始界面 重新调起登录操作
204 login(); 194 login();
205 } 195 }
206 }); 196 });
207 - PoolSdkHelper.trackEvent(getApplicationContext(), PoolEventType.POOL_RES_LOADED, null);
208 197
209 - //开启公共SDK的防沉迷功能 198 + //开启公共SDK的防沉迷功能,国内游戏按需使用,海外游戏无需接入
210 PoolSdkAntiAddiction.isUseAntiAddiction = true; 199 PoolSdkAntiAddiction.isUseAntiAddiction = true;
211 //PoolSdkAntiAddiction.isUseAntiAddictionToast = true;//防沉迷相关toast提示(默认关闭) 200 //PoolSdkAntiAddiction.isUseAntiAddictionToast = true;//防沉迷相关toast提示(默认关闭)
212 } 201 }
...@@ -289,11 +278,15 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -289,11 +278,15 @@ public class AppActivity extends Activity implements OnClickListener {
289 PoolSdkHelper.onWindowAttributesChanged(params); 278 PoolSdkHelper.onWindowAttributesChanged(params);
290 } 279 }
291 280
281 + //返回键退出游戏时 显示退出界面
292 @Override 282 @Override
293 public boolean dispatchKeyEvent(KeyEvent pKeyEvent) { 283 public boolean dispatchKeyEvent(KeyEvent pKeyEvent) {
294 if (pKeyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK 284 if (pKeyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK
295 && pKeyEvent.getAction() == KeyEvent.ACTION_DOWN) { 285 && pKeyEvent.getAction() == KeyEvent.ACTION_DOWN) {
286 +
287 + //判断当前SDK是否自带退出界面
296 if (PoolSdkHelper.hasExitDialog()) { 288 if (PoolSdkHelper.hasExitDialog()) {
289 + //显示SDK的退出界面
297 PoolSdkHelper.showExitDialog(new PoolExitDialogListener() { 290 PoolSdkHelper.showExitDialog(new PoolExitDialogListener() {
298 @Override 291 @Override
299 public void onDialogResult(int code, String msg) { 292 public void onDialogResult(int code, String msg) {
...@@ -314,7 +307,7 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -314,7 +307,7 @@ public class AppActivity extends Activity implements OnClickListener {
314 } 307 }
315 }); 308 });
316 } else { 309 } else {
317 - // TODO: 调用游戏的退出界面 310 + //SDK无退出界面,调用游戏自己的退出界面
318 showGameExitTips(); 311 showGameExitTips();
319 } 312 }
320 return false; 313 return false;
...@@ -322,66 +315,6 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -322,66 +315,6 @@ public class AppActivity extends Activity implements OnClickListener {
322 return super.dispatchKeyEvent(pKeyEvent); 315 return super.dispatchKeyEvent(pKeyEvent);
323 } 316 }
324 317
325 - private void showGameExitTips() {
326 - AlertDialog.Builder dialog = new AlertDialog.Builder(this);
327 - int ic_dialog_alert_id = getRedIdByName("ic_dialog_alert", "drawable");
328 - dialog.setIcon(ic_dialog_alert_id);
329 - dialog.setTitle("提示");
330 - dialog.setMessage("是否退出游戏?");
331 - dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
332 - @Override
333 - public void onClick(DialogInterface dialog, int which) {
334 - PoolSdkHelper.exitGame(new PoolExitListener() {
335 - @Override
336 - public void onExitGame() {
337 - finish();
338 - }
339 - });
340 - }
341 - });
342 - dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
343 - @Override
344 - public void onClick(DialogInterface dialog, int which) {
345 - dialog.dismiss();
346 - }
347 - });
348 - dialog.show();
349 - }
350 -
351 - private int getRedIdByName(String resName, String resType) {
352 - return getResources().getIdentifier(resName, resType, getPackageName());
353 - }
354 -
355 - private void initView(){
356 - btLogin = (Button) findViewById(getRedIdByName("pb_bt_login", "id"));
357 - btEnterGame = (Button) findViewById(getRedIdByName("pb_bt_entergame", "id"));
358 - btPay = (Button) findViewById(getRedIdByName("pb_bt_pay", "id"));
359 - btLogout = (Button) findViewById(getRedIdByName("pb_bt_logout", "id"));
360 - btSubRoleInfo = (Button) findViewById(getRedIdByName("pb_bt_subrole", "id"));
361 - btOpenChannel = (Button) findViewById(getRedIdByName("pb_bt_openchannel", "id"));
362 - btSwitchAcc = (Button) findViewById(getRedIdByName("pb_bt_switchacc", "id"));
363 - btOpenBbs = (Button) findViewById(getRedIdByName("pb_bt_openbbs", "id"));
364 - btQueryProducts = findViewById(getRedIdByName("pool_query_products_id","id"));
365 - pb_bt_verifyname = (Button) findViewById(getRedIdByName("pb_bt_verifyname", "id"));
366 -
367 - txMsg = (TextView) findViewById(getRedIdByName("tx_msg", "id"));
368 - txSdkMsg = (TextView) findViewById(getRedIdByName("tx_sdk_msg", "id"));
369 -
370 - btLogin.setOnClickListener(this);
371 - btEnterGame.setOnClickListener(this);
372 - btPay.setOnClickListener(this);
373 - btLogout.setOnClickListener(this);
374 - btSubRoleInfo.setOnClickListener(this);
375 - btOpenChannel.setOnClickListener(this);
376 - btSwitchAcc.setOnClickListener(this);
377 - btOpenBbs.setOnClickListener(this);
378 - btQueryProducts.setOnClickListener(this);
379 - pb_bt_verifyname.setOnClickListener(this);
380 - }
381 -
382 - public void yaOnClick(View view) {
383 - }
384 -
385 @Override 318 @Override
386 public void onClick(View view) { 319 public void onClick(View view) {
387 //新view 320 //新view
...@@ -393,7 +326,7 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -393,7 +326,7 @@ public class AppActivity extends Activity implements OnClickListener {
393 }else if (view == btPay) { 326 }else if (view == btPay) {
394 pay(); 327 pay();
395 }else if (view == btLogout) { 328 }else if (view == btLogout) {
396 - logout(); 329 + //logout();
397 }else if (view == btSubRoleInfo) { 330 }else if (view == btSubRoleInfo) {
398 //角色升级 331 //角色升级
399 submitRoleData(11,PoolRoleInfo.Type_RoleUpgrade); 332 submitRoleData(11,PoolRoleInfo.Type_RoleUpgrade);
...@@ -407,7 +340,8 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -407,7 +340,8 @@ public class AppActivity extends Activity implements OnClickListener {
407 queryProducts(); 340 queryProducts();
408 }else if (view == pb_bt_verifyname){ 341 }else if (view == pb_bt_verifyname){
409 //Toast.makeText(this,PoolSdkHelper.verifyRealName(this),Toast.LENGTH_SHORT).show(); 342 //Toast.makeText(this,PoolSdkHelper.verifyRealName(this),Toast.LENGTH_SHORT).show();
410 - //渠道无实名认证功能时,可以调用公共SDK的实名认证接口,在登录成功后才可以调用 343 +
344 + //渠道无实名认证功能时,可以调用公共SDK的实名认证接口,在登录成功后才可以调用,海外游戏无需接入,国内游戏按需使用
411 PoolSdkHelper.setUserIDInfo("尚福乐", "211322198509260317", new PoolSdkAntiAddictionUserInfoListener() { 345 PoolSdkHelper.setUserIDInfo("尚福乐", "211322198509260317", new PoolSdkAntiAddictionUserInfoListener() {
412 @Override 346 @Override
413 public void onSuccess(int totalGameTime, int totalPayMoney, String ymd) { 347 public void onSuccess(int totalGameTime, int totalPayMoney, String ymd) {
...@@ -433,6 +367,7 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -433,6 +367,7 @@ public class AppActivity extends Activity implements OnClickListener {
433 } 367 }
434 368
435 private void trackEvent(){ 369 private void trackEvent(){
370 + //使用AF和FB 等统计功能 需要调用该统计接口 value 具体参考文档
436 Map<String,Object> valueMap = new HashMap<>(); 371 Map<String,Object> valueMap = new HashMap<>();
437 valueMap.put(PoolEventParameterName.POOL_ORDER_ID,System.currentTimeMillis()+"");//订单号 372 valueMap.put(PoolEventParameterName.POOL_ORDER_ID,System.currentTimeMillis()+"");//订单号
438 valueMap.put(PoolEventParameterName.POOL_CURRENCY,"USD");//货币类型 USD:美元 CNY:人民币 373 valueMap.put(PoolEventParameterName.POOL_CURRENCY,"USD");//货币类型 USD:美元 CNY:人民币
...@@ -440,34 +375,13 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -440,34 +375,13 @@ public class AppActivity extends Activity implements OnClickListener {
440 PoolSdkHelper.trackEvent(getApplicationContext(), PoolEventType.POOL_RES_LOADED,valueMap); 375 PoolSdkHelper.trackEvent(getApplicationContext(), PoolEventType.POOL_RES_LOADED,valueMap);
441 } 376 }
442 377
443 - private void logout(){
444 -// if(PoolSdkHelper.hasLogout()){
445 -// PoolSdkHelper.logout(this);//结果回调通知到PoolLogoutListener
446 -// }
447 - }
448 -
449 - private void upTx(final String msg){
450 - mContext.runOnUiThread(new Runnable() {
451 -
452 - @Override
453 - public void run() {
454 - txMsg.setText(msg);
455 - }
456 - });
457 -// new Handler().post(new Runnable() {
458 -//
459 -// @Override
460 -// public void run() {
461 -// txMsg.setText(msg);
462 -// }
463 -// });
464 - }
465 -
466 private void login() { 378 private void login() {
467 PoolSdkLog.logError("调用login"); 379 PoolSdkLog.logError("调用login");
380 + //调用Poolsdk 登录接口
468 PoolSdkHelper.login("登录自定义字段", new PoolLoginListener() { 381 PoolSdkHelper.login("登录自定义字段", new PoolLoginListener() {
469 @Override 382 @Override
470 public void onLoginSuccess(PoolLoginInfo poolLoginInfo) { 383 public void onLoginSuccess(PoolLoginInfo poolLoginInfo) {
384 +
471 final String userType = poolLoginInfo.getUserType(); 385 final String userType = poolLoginInfo.getUserType();
472 final String timestamp = poolLoginInfo.getTimestamp(); 386 final String timestamp = poolLoginInfo.getTimestamp();
473 final String serverSign = poolLoginInfo.getServerSign(); 387 final String serverSign = poolLoginInfo.getServerSign();
...@@ -489,11 +403,13 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -489,11 +403,13 @@ public class AppActivity extends Activity implements OnClickListener {
489 } 403 }
490 }); 404 });
491 405
492 - 406 + //单机游戏无服务端支付结果查询接口,网游无需接入
493 PoolPayOrderConfirmHandler.getInstance(this, 2000, 1000).startOrderConfirmOp(mPoolPayListener); 407 PoolPayOrderConfirmHandler.getInstance(this, 2000, 1000).startOrderConfirmOp(mPoolPayListener);
494 } 408 }
495 409
496 private void pay() { 410 private void pay() {
411 +
412 + //Poolsdk 支付接口
497 final PoolPayInfo poolPayInfo = new PoolPayInfo(); 413 final PoolPayInfo poolPayInfo = new PoolPayInfo();
498 414
499 /******************************************** 415 /********************************************
...@@ -595,7 +511,8 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -595,7 +511,8 @@ public class AppActivity extends Activity implements OnClickListener {
595 PoolSdkHelper.logout(this);//注销成功后结果回调通知到PoolLogoutListener中 511 PoolSdkHelper.logout(this);//注销成功后结果回调通知到PoolLogoutListener中
596 }else if(PoolSdkHelper.hasSwitchAccount()){ 512 }else if(PoolSdkHelper.hasSwitchAccount()){
597 PoolSdkHelper.switchAccount(this);//切换成功后回回调结果到登录成功通知中(与登录通知数据一样) 513 PoolSdkHelper.switchAccount(this);//切换成功后回回调结果到登录成功通知中(与登录通知数据一样)
598 - }else{//渠道不存在注销和切换账号接口,游戏可自定处理逻辑 514 + }else{
515 + //渠道不存在注销和切换账号接口,游戏可自定处理逻辑,退出当前角色,回到初始界面重新调用登录接口
599 } 516 }
600 } 517 }
601 518
...@@ -611,7 +528,7 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -611,7 +528,7 @@ public class AppActivity extends Activity implements OnClickListener {
611 } 528 }
612 529
613 /** 530 /**
614 - * 商品查询接口 531 + * 商品查询接口,用于谷歌支付,在商品列表中显示当地货币价格,回到在初始化接口中
615 */ 532 */
616 private void queryProducts(){ 533 private void queryProducts(){
617 PoolSdkLog.logError(PoolSdkHelper.hasFunction("hasQueryWithProducts") + "SSS"); 534 PoolSdkLog.logError(PoolSdkHelper.hasFunction("hasQueryWithProducts") + "SSS");
...@@ -621,4 +538,106 @@ public class AppActivity extends Activity implements OnClickListener { ...@@ -621,4 +538,106 @@ public class AppActivity extends Activity implements OnClickListener {
621 PoolSdkHelper.callFunc("queryWithProducts",productMap); 538 PoolSdkHelper.callFunc("queryWithProducts",productMap);
622 } 539 }
623 540
541 +
542 +
543 + //---------------------------- SDK 相关 ↑ ------------------------------
544 +
545 + //新的view
546 + private Button btLogin;
547 + private Button btEnterGame;
548 + private Button btPay;
549 + private Button btLogout;
550 + private Button btSubRoleInfo;
551 + private Button btOpenChannel;
552 + private Button btSwitchAcc;
553 + private Button btOpenBbs;
554 + private Button btQueryProducts;
555 + private Button pb_bt_verifyname;
556 +
557 + private Bundle saveBundle;
558 + //提示LOG
559 + private TextView txMsg,txSdkMsg;
560 + private Activity mContext;
561 +
562 +
563 + private void showGameExitTips() {
564 + AlertDialog.Builder dialog = new AlertDialog.Builder(this);
565 + int ic_dialog_alert_id = getRedIdByName("ic_dialog_alert", "drawable");
566 + dialog.setIcon(ic_dialog_alert_id);
567 + dialog.setTitle("提示");
568 + dialog.setMessage("是否退出游戏?");
569 + dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
570 + @Override
571 + public void onClick(DialogInterface dialog, int which) {
572 + PoolSdkHelper.exitGame(new PoolExitListener() {
573 + @Override
574 + public void onExitGame() {
575 + finish();
576 + }
577 + });
578 + }
579 + });
580 + dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
581 + @Override
582 + public void onClick(DialogInterface dialog, int which) {
583 + dialog.dismiss();
584 + }
585 + });
586 + dialog.show();
587 + }
588 +
589 + private int getRedIdByName(String resName, String resType) {
590 + return getResources().getIdentifier(resName, resType, getPackageName());
591 + }
592 +
593 + private void initView(){
594 + int layoutId = getResources().getIdentifier("public_sdk_self_test", "layout", getPackageName());
595 + setContentView(layoutId);
596 + mContext = this;
597 +
598 + btLogin = (Button) findViewById(getRedIdByName("pb_bt_login", "id"));
599 + btEnterGame = (Button) findViewById(getRedIdByName("pb_bt_entergame", "id"));
600 + btPay = (Button) findViewById(getRedIdByName("pb_bt_pay", "id"));
601 + btLogout = (Button) findViewById(getRedIdByName("pb_bt_logout", "id"));
602 + btSubRoleInfo = (Button) findViewById(getRedIdByName("pb_bt_subrole", "id"));
603 + btOpenChannel = (Button) findViewById(getRedIdByName("pb_bt_openchannel", "id"));
604 + btSwitchAcc = (Button) findViewById(getRedIdByName("pb_bt_switchacc", "id"));
605 + btOpenBbs = (Button) findViewById(getRedIdByName("pb_bt_openbbs", "id"));
606 + btQueryProducts = findViewById(getRedIdByName("pool_query_products_id","id"));
607 + pb_bt_verifyname = (Button) findViewById(getRedIdByName("pb_bt_verifyname", "id"));
608 +
609 + txMsg = (TextView) findViewById(getRedIdByName("tx_msg", "id"));
610 + txSdkMsg = (TextView) findViewById(getRedIdByName("tx_sdk_msg", "id"));
611 +
612 + btLogin.setOnClickListener(this);
613 + btEnterGame.setOnClickListener(this);
614 + btPay.setOnClickListener(this);
615 + btLogout.setOnClickListener(this);
616 + btSubRoleInfo.setOnClickListener(this);
617 + btOpenChannel.setOnClickListener(this);
618 + btSwitchAcc.setOnClickListener(this);
619 + btOpenBbs.setOnClickListener(this);
620 + btQueryProducts.setOnClickListener(this);
621 + pb_bt_verifyname.setOnClickListener(this);
622 + }
623 +
624 + public void yaOnClick(View view) {
625 + }
626 +
627 + private void upTx(final String msg){
628 + mContext.runOnUiThread(new Runnable() {
629 +
630 + @Override
631 + public void run() {
632 + txMsg.setText(msg);
633 + }
634 + });
635 +// new Handler().post(new Runnable() {
636 +//
637 +// @Override
638 +// public void run() {
639 +// txMsg.setText(msg);
640 +// }
641 +// });
642 + }
624 } 643 }
......
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <resources> 2 <resources>
3 - 3 + <string name="app_name">PoolSDK_Demo</string>
4 - <string name="app_name">Demo_shenshou</string>
5 -
6 </resources> 4 </resources>
......