Toggle navigation
Toggle navigation
This project
Loading...
Sign in
public_service
/
public_sdk_android
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
lizhihui
2020-12-29 10:55:11 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
02aae8772776663c4c342f071ceadf074af024cb
02aae877
1 parent
9d49d8d2
update demo
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
209 additions
and
180 deletions
demo/.idea/compiler.xml
demo/.idea/gradle.xml
demo/.idea/jarRepositories.xml
demo/.idea/misc.xml
demo/app/build.gradle
demo/app/src/main/AndroidManifest.xml
demo/app/src/main/java/com/youai/foolsdk/demo/AppActivity.java
demo/app/src/main/res/values/public_sdk_self_strings.xml
demo/.idea/compiler.xml
0 → 100644
View file @
02aae87
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"CompilerConfiguration"
>
<bytecodeTargetLevel
target=
"1.8"
/>
</component>
</project>
\ No newline at end of file
demo/.idea/gradle.xml
View file @
02aae87
...
...
@@ -14,6 +14,7 @@
</set>
</option>
<option
name=
"resolveModulePerSourceSet"
value=
"false"
/>
<option
name=
"useQualifiedModuleNames"
value=
"true"
/>
</GradleProjectSettings>
</option>
</component>
...
...
demo/.idea/jarRepositories.xml
0 → 100644
View file @
02aae87
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"RemoteRepositoriesConfiguration"
>
<remote-repository>
<option
name=
"id"
value=
"central"
/>
<option
name=
"name"
value=
"Maven Central repository"
/>
<option
name=
"url"
value=
"https://repo1.maven.org/maven2"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"jboss.community"
/>
<option
name=
"name"
value=
"JBoss Community repository"
/>
<option
name=
"url"
value=
"https://repository.jboss.org/nexus/content/repositories/public/"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"BintrayJCenter"
/>
<option
name=
"name"
value=
"BintrayJCenter"
/>
<option
name=
"url"
value=
"https://jcenter.bintray.com/"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"Google"
/>
<option
name=
"name"
value=
"Google"
/>
<option
name=
"url"
value=
"https://dl.google.com/dl/android/maven2/"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"D:\AndroidSDK\extras\m2repository"
/>
<option
name=
"name"
value=
"D:\AndroidSDK\extras\m2repository"
/>
<option
name=
"url"
value=
"file:/$PROJECT_DIR$/../../../AndroidSDK/extras/m2repository"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"D:\AndroidSDK\extras\google\m2repository"
/>
<option
name=
"name"
value=
"D:\AndroidSDK\extras\google\m2repository"
/>
<option
name=
"url"
value=
"file:/$PROJECT_DIR$/../../../AndroidSDK/extras/google/m2repository"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"D:\AndroidSDK\extras\android\m2repository"
/>
<option
name=
"name"
value=
"D:\AndroidSDK\extras\android\m2repository"
/>
<option
name=
"url"
value=
"file:/$PROJECT_DIR$/../../../AndroidSDK/extras/android/m2repository"
/>
</remote-repository>
</component>
</project>
\ No newline at end of file
demo/.idea/misc.xml
View file @
02aae87
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
7
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
8"
default=
"true
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
...
...
demo/app/build.gradle
View file @
02aae87
apply
plugin:
'com.android.application'
android
{
compileSdkVersion
2
8
compileSdkVersion
2
9
buildToolsVersion
'29.0.2'
defaultConfig
{
applicationId
"com.
ssjh
.demo"
minSdkVersion
14
targetSdkVersion
2
8
applicationId
"com.
poolsdk
.demo"
minSdkVersion
21
targetSdkVersion
2
9
versionCode
2
versionName
"1.0"
}
...
...
@@ -32,6 +32,6 @@ dependencies {
// implementation 'com.android.installreferrer:installreferrer:1.0'
// implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'
compile
'com.google.firebase:firebase-core:16.0.6'
compile
'com.google.firebase:firebase-messaging:17.3.4'
//
compile 'com.google.firebase:firebase-core:16.0.6'
//
compile 'com.google.firebase:firebase-messaging:17.3.4'
}
...
...
demo/app/src/main/AndroidManifest.xml
View file @
02aae87
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.
youai.demo.shenshou
"
>
package=
"com.
poolsdk.demo
"
>
<!-- SDK start -->
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<
uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/
>
<
!-- 国内需要用公共SDK的后台数据功能需要以下权限 --
>
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.SYSTEM_ALERT_WINDOW"
/>
<uses-permission
android:name=
"android.permission.GET_TASKS"
/>
<uses-permission
android:name=
"android.permission.CHANGE_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.RECORD_AUDIO"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<!-- SDK end -->
<application
android:name=
"com.gzpublic.app.sdk.application.PoolSDKApplication"
android:allowBackup=
"false"
android:icon=
"@drawable/public_sdk_self_ic_launcher"
android:label=
"@string/app_name"
>
android:label=
"@string/app_name"
>
<activity
android:name=
"com.youai.foolsdk.demo.AppActivity"
android:configChanges=
"keyboardHidden|orientation|screenSize"
android:label=
"@string/app_name"
android:screenOrientation=
"portrait"
android:theme=
"@android:style/Theme.NoTitleBar.Fullscreen"
>
android:theme=
"@android:style/Theme.NoTitleBar.Fullscreen"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<!-- SDK start -->
<activity
android:name=
"com.appsdk.sdk.YouaiSDK"
android:label=
"youai_sdk"
android:launchMode=
"singleTask"
android:theme=
"@android:style/Theme.Dialog"
/>
<service
android:name=
"com.appsdk.sdk.YouaiService"
android:enabled=
"true"
>
<intent-filter>
<action
android:name=
"com.youai.sdk.YouaiService"
/>
</intent-filter>
</service>
<receiver
android:name=
"com.appsdk.sdk.Receiver"
>
<intent-filter>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</receiver>
<!-- SDK start -->
<activity
android:name=
"com.alipay.sdk.app.H5PayActivity"
android:configChanges=
"keyboardHidden|navigation|orientation"
android:exported=
"false"
android:screenOrientation=
"behind"
/>
<activity
android:name=
"com.alipay.sdk.auth.AuthActivity"
android:configChanges=
"keyboardHidden|navigation|orientation"
android:exported=
"false"
android:screenOrientation=
"behind"
/>
<!-- SDK end -->
</application>
...
...
demo/app/src/main/java/com/youai/foolsdk/demo/AppActivity.java
View file @
02aae87
...
...
@@ -3,21 +3,18 @@ package com.youai.foolsdk.demo;
import
android.Manifest
;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.app.Application
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.res.Configuration
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.view.WindowManager.LayoutParams
;
import
android.widget.Button
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.gzpublic.app.sdk.framework.PoolEventParameterName
;
import
com.gzpublic.app.sdk.framework.PoolEventType
;
...
...
@@ -30,7 +27,6 @@ import com.gzpublic.app.sdk.framework.PoolLogoutListener;
import
com.gzpublic.app.sdk.framework.PoolPayInfo
;
import
com.gzpublic.app.sdk.framework.PoolPayListener
;
import
com.gzpublic.app.sdk.framework.PoolPayOrderConfirmHandler
;
import
com.gzpublic.app.sdk.framework.PoolReport
;
import
com.gzpublic.app.sdk.framework.PoolRoleInfo
;
import
com.gzpublic.app.sdk.framework.PoolRoleListener
;
import
com.gzpublic.app.sdk.framework.PoolSDKCallBackListener
;
...
...
@@ -45,31 +41,18 @@ import org.json.JSONException;
import
org.json.JSONObject
;
import
java.util.HashMap
;
import
java.util.Locale
;
import
java.util.Map
;
public
class
AppActivity
extends
Activity
implements
OnClickListener
{
//新的view
private
Button
btLogin
;
private
Button
btEnterGame
;
private
Button
btPay
;
private
Button
btLogout
;
private
Button
btSubRoleInfo
;
private
Button
btOpenChannel
;
private
Button
btSwitchAcc
;
private
Button
btOpenBbs
;
private
Button
btQueryProducts
;
private
Button
pb_bt_verifyname
;
private
Bundle
saveBundle
;
//提示LOG
private
TextView
txMsg
,
txSdkMsg
;
private
Activity
mContext
;
private
PoolPayListener
mPoolPayListener
=
new
PoolPayListener
()
{
private
PoolPayListener
mPoolPayListener
=
new
PoolPayListener
()
{
@Override
public
void
onPaySuccess
(
String
paramCustom
)
{
//支付回调以服务端通知为准
// TODO Auto-generated method stub
public
void
onPaySuccess
(
String
paramCustom
)
{
//支付回调以服务端通知为准
upTx
(
"支付成功回调:"
+
paramCustom
);
//[{"orderId":"20180116114151740535D825","state":0,"productId":"1","productName":"金币","amout":0}]
if
(
paramCustom
==
null
||
paramCustom
.
length
()
<=
0
)
{
...
...
@@ -94,22 +77,19 @@ public class AppActivity extends Activity implements OnClickListener {
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
upTx
(
"支付成功回调:"
+
paramCustom
);
}
@Override
public
void
onPayFailed
(
String
paramCustom
,
String
errorMsg
)
{
// TODO Auto-generated method stub
System
.
out
.
println
(
"支付失败回调:"
+
paramCustom
+
"; errorMsg:"
+
errorMsg
);
upTx
(
"支付失败回调:"
+
paramCustom
+
"; errorMsg:"
+
errorMsg
);
System
.
out
.
println
(
"支付失败回调:"
+
paramCustom
+
"; errorMsg:"
+
errorMsg
);
upTx
(
"支付失败回调:"
+
paramCustom
+
"; errorMsg:"
+
errorMsg
);
}
};
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
String
[]
permissions
,
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
PoolSdkHelper
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
init
(
saveBundle
);
}
...
...
@@ -118,17 +98,17 @@ public class AppActivity extends Activity implements OnClickListener {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
saveBundle
=
savedInstanceState
;
int
layoutId
=
getResources
().
getIdentifier
(
"public_sdk_self_test"
,
"layout"
,
getPackageName
());
setContentView
(
layoutId
);
mContext
=
this
;
initView
();
PoolSdkLog
.
setIsShowLog
(
true
);
PoolSdkConfig
.
readPoolSdkConfigData
(
this
);
//国内游戏接入如果需要使用平台统计等功能,需要获取手机识别号和读写SD卡权限再调用初始化接口
if
(
getApplicationInfo
().
targetSdkVersion
>=
23
&&
Build
.
VERSION
.
SDK_INT
>=
23
){
requestPermissions
(
new
String
[]{
Manifest
.
permission
.
READ_PHONE_STATE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
},
1
);
}
else
{
//不需要权限直接调用init
}
else
{
//不需要权限直接调用init
this
.
init
(
savedInstanceState
);
}
...
...
@@ -140,16 +120,18 @@ public class AppActivity extends Activity implements OnClickListener {
}
private
void
init
(
Bundle
savedInstanceState
){
//PoolSDK初始化接口
PoolSdkHelper
.
init
(
this
,
new
PoolSDKCallBackListener
()
{
@Override
public
void
poolSdkCallBack
(
int
code
,
String
msg
)
{
PoolSdkLog
.
logInfo
(
"poolSdkCallBack:code:"
+
code
+
",msg:"
+
msg
);
upTx
(
"poolSdkCallBack:code:"
+
code
+
",msg:"
+
msg
);
switch
(
code
)
{
case
PoolSDKCode
.
POOLSDK_INIT_SUCCESS
:
// 初始化成功
case
PoolSDKCode
.
POOLSDK_INIT_SUCCESS
:
// 初始化成功,游戏可以调用登录接口
PoolSdkLog
.
logInfo
(
"游戏中收到初始化成功回调"
);
new
Handler
().
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
login
();
...
...
@@ -157,8 +139,10 @@ public class AppActivity extends Activity implements OnClickListener {
},
1000
);
break
;
case
PoolSDKCode
.
POOLSDK_INIT_FAIL
:
//初始化失败,游戏可以尝试重新调用初始化接口或退出游戏等操作
break
;
case
PoolSDKCode
.
POOLSDK_QUERY_WITH_PRODUCTS
:
//该接口为查询谷歌支付当地货币价格接口,国内游戏无需接入
//msg:为查询的结果值
/**
* {//查询商品信息返回数据
...
...
@@ -173,7 +157,8 @@ public class AppActivity extends Activity implements OnClickListener {
* }
*/
break
;
case
PoolSDKCode
.
POOLSDK_EXTENDS_CODE1
:
//实名认证成功才有回调
case
PoolSDKCode
.
POOLSDK_EXTENDS_CODE1
:
//实名认证成功才有回调
//msg为生日
break
;
...
...
@@ -195,18 +180,22 @@ public class AppActivity extends Activity implements OnClickListener {
}
}
},
savedInstanceState
);
// init(this);// this为游戏的activity对象
//设置支付回调接口监听
PoolSdkHelper
.
setPayListener
(
mPoolPayListener
);
//设置注销账号接口监听
PoolSdkHelper
.
setLogoutCallback
(
new
PoolLogoutListener
()
{
@Override
public
void
onLogoutSuccess
()
{
// TODO: 此处处理SDK登出的逻辑
PoolSdkLog
.
logInfo
(
"游戏中收到logoutSuccess回调"
);
PoolSdkLog
.
logInfo
(
"游戏中收到SDK logoutSuccess回调"
);
//游戏退出当前账号 回到初始界面 重新调起登录操作
login
();
}
});
PoolSdkHelper
.
trackEvent
(
getApplicationContext
(),
PoolEventType
.
POOL_RES_LOADED
,
null
);
//开启公共SDK的防沉迷功能
//开启公共SDK的防沉迷功能
,国内游戏按需使用,海外游戏无需接入
PoolSdkAntiAddiction
.
isUseAntiAddiction
=
true
;
//PoolSdkAntiAddiction.isUseAntiAddictionToast = true;//防沉迷相关toast提示(默认关闭)
}
...
...
@@ -289,11 +278,15 @@ public class AppActivity extends Activity implements OnClickListener {
PoolSdkHelper
.
onWindowAttributesChanged
(
params
);
}
//返回键退出游戏时 显示退出界面
@Override
public
boolean
dispatchKeyEvent
(
KeyEvent
pKeyEvent
)
{
if
(
pKeyEvent
.
getKeyCode
()
==
KeyEvent
.
KEYCODE_BACK
&&
pKeyEvent
.
getAction
()
==
KeyEvent
.
ACTION_DOWN
)
{
//判断当前SDK是否自带退出界面
if
(
PoolSdkHelper
.
hasExitDialog
())
{
//显示SDK的退出界面
PoolSdkHelper
.
showExitDialog
(
new
PoolExitDialogListener
()
{
@Override
public
void
onDialogResult
(
int
code
,
String
msg
)
{
...
...
@@ -314,7 +307,7 @@ public class AppActivity extends Activity implements OnClickListener {
}
});
}
else
{
//
TODO: 调用游戏
的退出界面
//
SDK无退出界面,调用游戏自己
的退出界面
showGameExitTips
();
}
return
false
;
...
...
@@ -322,66 +315,6 @@ public class AppActivity extends Activity implements OnClickListener {
return
super
.
dispatchKeyEvent
(
pKeyEvent
);
}
private
void
showGameExitTips
()
{
AlertDialog
.
Builder
dialog
=
new
AlertDialog
.
Builder
(
this
);
int
ic_dialog_alert_id
=
getRedIdByName
(
"ic_dialog_alert"
,
"drawable"
);
dialog
.
setIcon
(
ic_dialog_alert_id
);
dialog
.
setTitle
(
"提示"
);
dialog
.
setMessage
(
"是否退出游戏?"
);
dialog
.
setPositiveButton
(
"确定"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
PoolSdkHelper
.
exitGame
(
new
PoolExitListener
()
{
@Override
public
void
onExitGame
()
{
finish
();
}
});
}
});
dialog
.
setNegativeButton
(
"取消"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
}
});
dialog
.
show
();
}
private
int
getRedIdByName
(
String
resName
,
String
resType
)
{
return
getResources
().
getIdentifier
(
resName
,
resType
,
getPackageName
());
}
private
void
initView
(){
btLogin
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_login"
,
"id"
));
btEnterGame
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_entergame"
,
"id"
));
btPay
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_pay"
,
"id"
));
btLogout
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_logout"
,
"id"
));
btSubRoleInfo
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_subrole"
,
"id"
));
btOpenChannel
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_openchannel"
,
"id"
));
btSwitchAcc
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_switchacc"
,
"id"
));
btOpenBbs
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_openbbs"
,
"id"
));
btQueryProducts
=
findViewById
(
getRedIdByName
(
"pool_query_products_id"
,
"id"
));
pb_bt_verifyname
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_verifyname"
,
"id"
));
txMsg
=
(
TextView
)
findViewById
(
getRedIdByName
(
"tx_msg"
,
"id"
));
txSdkMsg
=
(
TextView
)
findViewById
(
getRedIdByName
(
"tx_sdk_msg"
,
"id"
));
btLogin
.
setOnClickListener
(
this
);
btEnterGame
.
setOnClickListener
(
this
);
btPay
.
setOnClickListener
(
this
);
btLogout
.
setOnClickListener
(
this
);
btSubRoleInfo
.
setOnClickListener
(
this
);
btOpenChannel
.
setOnClickListener
(
this
);
btSwitchAcc
.
setOnClickListener
(
this
);
btOpenBbs
.
setOnClickListener
(
this
);
btQueryProducts
.
setOnClickListener
(
this
);
pb_bt_verifyname
.
setOnClickListener
(
this
);
}
public
void
yaOnClick
(
View
view
)
{
}
@Override
public
void
onClick
(
View
view
)
{
//新view
...
...
@@ -393,7 +326,7 @@ public class AppActivity extends Activity implements OnClickListener {
}
else
if
(
view
==
btPay
)
{
pay
();
}
else
if
(
view
==
btLogout
)
{
logout
();
//
logout();
}
else
if
(
view
==
btSubRoleInfo
)
{
//角色升级
submitRoleData
(
11
,
PoolRoleInfo
.
Type_RoleUpgrade
);
...
...
@@ -407,7 +340,8 @@ public class AppActivity extends Activity implements OnClickListener {
queryProducts
();
}
else
if
(
view
==
pb_bt_verifyname
){
//Toast.makeText(this,PoolSdkHelper.verifyRealName(this),Toast.LENGTH_SHORT).show();
//渠道无实名认证功能时,可以调用公共SDK的实名认证接口,在登录成功后才可以调用
//渠道无实名认证功能时,可以调用公共SDK的实名认证接口,在登录成功后才可以调用,海外游戏无需接入,国内游戏按需使用
PoolSdkHelper
.
setUserIDInfo
(
"尚福乐"
,
"211322198509260317"
,
new
PoolSdkAntiAddictionUserInfoListener
()
{
@Override
public
void
onSuccess
(
int
totalGameTime
,
int
totalPayMoney
,
String
ymd
)
{
...
...
@@ -433,6 +367,7 @@ public class AppActivity extends Activity implements OnClickListener {
}
private
void
trackEvent
(){
//使用AF和FB 等统计功能 需要调用该统计接口 value 具体参考文档
Map
<
String
,
Object
>
valueMap
=
new
HashMap
<>();
valueMap
.
put
(
PoolEventParameterName
.
POOL_ORDER_ID
,
System
.
currentTimeMillis
()+
""
);
//订单号
valueMap
.
put
(
PoolEventParameterName
.
POOL_CURRENCY
,
"USD"
);
//货币类型 USD:美元 CNY:人民币
...
...
@@ -440,34 +375,13 @@ public class AppActivity extends Activity implements OnClickListener {
PoolSdkHelper
.
trackEvent
(
getApplicationContext
(),
PoolEventType
.
POOL_RES_LOADED
,
valueMap
);
}
private
void
logout
(){
// if(PoolSdkHelper.hasLogout()){
// PoolSdkHelper.logout(this);//结果回调通知到PoolLogoutListener
// }
}
private
void
upTx
(
final
String
msg
){
mContext
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
txMsg
.
setText
(
msg
);
}
});
// new Handler().post(new Runnable() {
//
// @Override
// public void run() {
// txMsg.setText(msg);
// }
// });
}
private
void
login
()
{
PoolSdkLog
.
logError
(
"调用login"
);
//调用Poolsdk 登录接口
PoolSdkHelper
.
login
(
"登录自定义字段"
,
new
PoolLoginListener
()
{
@Override
public
void
onLoginSuccess
(
PoolLoginInfo
poolLoginInfo
)
{
final
String
userType
=
poolLoginInfo
.
getUserType
();
final
String
timestamp
=
poolLoginInfo
.
getTimestamp
();
final
String
serverSign
=
poolLoginInfo
.
getServerSign
();
...
...
@@ -489,11 +403,13 @@ public class AppActivity extends Activity implements OnClickListener {
}
});
//单机游戏无服务端支付结果查询接口,网游无需接入
PoolPayOrderConfirmHandler
.
getInstance
(
this
,
2000
,
1000
).
startOrderConfirmOp
(
mPoolPayListener
);
}
private
void
pay
()
{
//Poolsdk 支付接口
final
PoolPayInfo
poolPayInfo
=
new
PoolPayInfo
();
/********************************************
...
...
@@ -595,7 +511,8 @@ public class AppActivity extends Activity implements OnClickListener {
PoolSdkHelper
.
logout
(
this
);
//注销成功后结果回调通知到PoolLogoutListener中
}
else
if
(
PoolSdkHelper
.
hasSwitchAccount
()){
PoolSdkHelper
.
switchAccount
(
this
);
//切换成功后回回调结果到登录成功通知中(与登录通知数据一样)
}
else
{
//渠道不存在注销和切换账号接口,游戏可自定处理逻辑
}
else
{
//渠道不存在注销和切换账号接口,游戏可自定处理逻辑,退出当前角色,回到初始界面重新调用登录接口
}
}
...
...
@@ -611,7 +528,7 @@ public class AppActivity extends Activity implements OnClickListener {
}
/**
* 商品查询接口
* 商品查询接口
,用于谷歌支付,在商品列表中显示当地货币价格,回到在初始化接口中
*/
private
void
queryProducts
(){
PoolSdkLog
.
logError
(
PoolSdkHelper
.
hasFunction
(
"hasQueryWithProducts"
)
+
"SSS"
);
...
...
@@ -621,4 +538,106 @@ public class AppActivity extends Activity implements OnClickListener {
PoolSdkHelper
.
callFunc
(
"queryWithProducts"
,
productMap
);
}
//---------------------------- SDK 相关 ↑ ------------------------------
//新的view
private
Button
btLogin
;
private
Button
btEnterGame
;
private
Button
btPay
;
private
Button
btLogout
;
private
Button
btSubRoleInfo
;
private
Button
btOpenChannel
;
private
Button
btSwitchAcc
;
private
Button
btOpenBbs
;
private
Button
btQueryProducts
;
private
Button
pb_bt_verifyname
;
private
Bundle
saveBundle
;
//提示LOG
private
TextView
txMsg
,
txSdkMsg
;
private
Activity
mContext
;
private
void
showGameExitTips
()
{
AlertDialog
.
Builder
dialog
=
new
AlertDialog
.
Builder
(
this
);
int
ic_dialog_alert_id
=
getRedIdByName
(
"ic_dialog_alert"
,
"drawable"
);
dialog
.
setIcon
(
ic_dialog_alert_id
);
dialog
.
setTitle
(
"提示"
);
dialog
.
setMessage
(
"是否退出游戏?"
);
dialog
.
setPositiveButton
(
"确定"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
PoolSdkHelper
.
exitGame
(
new
PoolExitListener
()
{
@Override
public
void
onExitGame
()
{
finish
();
}
});
}
});
dialog
.
setNegativeButton
(
"取消"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
}
});
dialog
.
show
();
}
private
int
getRedIdByName
(
String
resName
,
String
resType
)
{
return
getResources
().
getIdentifier
(
resName
,
resType
,
getPackageName
());
}
private
void
initView
(){
int
layoutId
=
getResources
().
getIdentifier
(
"public_sdk_self_test"
,
"layout"
,
getPackageName
());
setContentView
(
layoutId
);
mContext
=
this
;
btLogin
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_login"
,
"id"
));
btEnterGame
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_entergame"
,
"id"
));
btPay
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_pay"
,
"id"
));
btLogout
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_logout"
,
"id"
));
btSubRoleInfo
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_subrole"
,
"id"
));
btOpenChannel
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_openchannel"
,
"id"
));
btSwitchAcc
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_switchacc"
,
"id"
));
btOpenBbs
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_openbbs"
,
"id"
));
btQueryProducts
=
findViewById
(
getRedIdByName
(
"pool_query_products_id"
,
"id"
));
pb_bt_verifyname
=
(
Button
)
findViewById
(
getRedIdByName
(
"pb_bt_verifyname"
,
"id"
));
txMsg
=
(
TextView
)
findViewById
(
getRedIdByName
(
"tx_msg"
,
"id"
));
txSdkMsg
=
(
TextView
)
findViewById
(
getRedIdByName
(
"tx_sdk_msg"
,
"id"
));
btLogin
.
setOnClickListener
(
this
);
btEnterGame
.
setOnClickListener
(
this
);
btPay
.
setOnClickListener
(
this
);
btLogout
.
setOnClickListener
(
this
);
btSubRoleInfo
.
setOnClickListener
(
this
);
btOpenChannel
.
setOnClickListener
(
this
);
btSwitchAcc
.
setOnClickListener
(
this
);
btOpenBbs
.
setOnClickListener
(
this
);
btQueryProducts
.
setOnClickListener
(
this
);
pb_bt_verifyname
.
setOnClickListener
(
this
);
}
public
void
yaOnClick
(
View
view
)
{
}
private
void
upTx
(
final
String
msg
){
mContext
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
txMsg
.
setText
(
msg
);
}
});
// new Handler().post(new Runnable() {
//
// @Override
// public void run() {
// txMsg.setText(msg);
// }
// });
}
}
...
...
demo/app/src/main/res/values/public_sdk_self_strings.xml
View file @
02aae87
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name=
"app_name"
>
Demo_shenshou
</string>
<string
name=
"app_name"
>
PoolSDK_Demo
</string>
</resources>
...
...
Please
register
or
login
to post a comment