1556138063

add public android sdk

Showing 41 changed files with 843 additions and 0 deletions
No preview for this file type
<?xml version="1.0" encoding="utf-8"?>
<config>
<sdkconfig
appClientKey="9DtxPtUrzYU0uTBGGMJzKyhKAK5t2O9i"
appId="Dz8T95TrG9d/WVIWAPZviuaV7Tbko3oAlqDCYpNKkTU="
channelparameter1="4uc0/gEfNt4="
channelparameter2="4uc0/gEfNt4="
custom="T7w9VvhA5tQ="
gamechannelid="4uc0/gEfNt4="
gamesimplename="qcFlv/sgri8oQ6xDbE0odg=="
logincheckurl="Xwm2VZk4IZHw4pR8WSu0JRSPl5jMDzA8+5nKH+jNJckQW+5uHcG5Mxl+gMWO6s8PhqrR0VX7irk="
paycheckurl="Xwm2VZk4IZHw4pR8WSu0JRSPl5jMDzA8+5nKH+jNJclRWohb/BPqZ4ChH88g5ubtvsBW3D32B8c="
payorderurl="Xwm2VZk4IZHw4pR8WSu0JRSPl5jMDzA8+5nKH+jNJclRWohb/BPqZ4SO5qrmq1RBsIoFXavzUfg="
sdksimplename="vWVsU5Ogkh8="
sdkversioncode="BVPAQexcXDk="
styleName="4N7gnKed6uk="
usertype="gssaXIIEiL0="
weixinId="x3d4hSeP9KFDTFusyU+iB/9NgyvRyoop"
payCallbackUrl = "http://51wang"
/>
</config>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Demo_PoolSdk</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
</pydev_project>
eclipse.preferences.version=1
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
@echo off
cd /d %~dp0
"%ANT_ROOT%\bin\ant" clean release -f build.xml
pause
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.youai.foolsdk.demo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<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" />
<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.READ_LOGS" />
<uses-permission android:name="android.permission.GET_TASKS" />
<application
android:name="com.gzyouai.publicsdk.application.PoolSDKApplication"
android:allowBackup="true"
android:icon="@drawable/public_sdk_self_ic_launcher"
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="landscape"
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>
<!-- start YouaiSDK -->
<receiver
android:name="com.gzyouai.fengniao.sdk.framework.AppInstallReceiver"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
<!-- start i9133 -->
<activity
android:name=".wxapi.WXPayEntryActivity"
android:exported="true"
android:launchMode="singleTop" />
<activity
android:name="com.youai.sdk.YouaiSDK"
android:label="youai_sdk"
android:theme="@android:style/Theme.Dialog" >
</activity>
<service
android:name="com.youai.sdk.YouaiService"
android:enabled="true" >
<intent-filter>
<action android:name="com.youai.sdk.YouaiService" />
</intent-filter>
</service>
<service
android:name="com.youai.sdk.FloatViewService"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="com.youai.sdk.FloatViewService" />
</intent-filter>
</service>
<receiver android:name="com.youai.sdk.Receiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" >
</action>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</receiver>
<activity
android:name="com.alipay.sdk.app.H5PayActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:exported="false"
android:screenOrientation="behind" >
</activity>
<activity
android:name="com.alipay.sdk.auth.AuthActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:exported="false"
android:screenOrientation="behind" >
</activity>
<!-- end i9133 -->
</application>
</manifest>
\ No newline at end of file
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.
<?xml version="1.0" encoding="utf-8"?>
<config>
<sdkconfig
appClientKey="9DtxPtUrzYU0uTBGGMJzKyhKAK5t2O9i"
appId="Dz8T95TrG9d/WVIWAPZviuaV7Tbko3oAlqDCYpNKkTU="
channelparameter1="4uc0/gEfNt4="
channelparameter2="4uc0/gEfNt4="
custom="T7w9VvhA5tQ="
gamechannelid="4uc0/gEfNt4="
gamesimplename="qcFlv/sgri8oQ6xDbE0odg=="
logincheckurl="Xwm2VZk4IZHw4pR8WSu0JRSPl5jMDzA8+5nKH+jNJckQW+5uHcG5Mxl+gMWO6s8PhqrR0VX7irk="
paycheckurl="Xwm2VZk4IZHw4pR8WSu0JRSPl5jMDzA8+5nKH+jNJclRWohb/BPqZ4ChH88g5ubtvsBW3D32B8c="
payorderurl="Xwm2VZk4IZHw4pR8WSu0JRSPl5jMDzA8+5nKH+jNJclRWohb/BPqZ4SO5qrmq1RBsIoFXavzUfg="
sdksimplename="vWVsU5Ogkh8="
sdkversioncode="BVPAQexcXDk="
styleName="yvfh/4zhaEQ="
usertype="gssaXIIEiL0="
weixinId="x3d4hSeP9KFDTFusyU+iB/9NgyvRyoop"
payCallbackUrl = "http://51wang"
/>
</config>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project name="PoolSdk" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>
\ No newline at end of file
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=D:\\android\\sdk
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-19
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/public_sdk_self_demo_btn_main_s" android:state_selected="true"/>
<item android:drawable="@drawable/public_sdk_self_demo_btn_main_s" android:state_pressed="true"/>
<item android:drawable="@drawable/public_sdk_self_demo_btn_main_n"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/public_sdk_self_demo_btn_login_s" android:state_selected="true"/>
<item android:drawable="@drawable/public_sdk_self_demo_btn_login_s" android:state_pressed="true"/>
<item android:drawable="@drawable/public_sdk_self_demo_btn_login_n"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/public_sdk_self_demo_main" >
<Button
android:id="@+id/ya_pay_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="14dp"
android:layout_marginTop="53dp"
android:background="@drawable/public_sdk_self_ya_bt_selector"
android:onClick="yaOnClick"/>
<Button
android:id="@+id/ya_submit_role_data_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/ya_pay_bt"
android:layout_alignParentBottom="true"
android:layout_marginBottom="75dp"
android:background="@drawable/public_sdk_self_ya_bt_selector"
android:onClick="yaOnClick"/>
<Button
android:id="@+id/ya_channel_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/ya_pay_bt"
android:background="@drawable/public_sdk_self_ya_bt_selector"
android:onClick="yaOnClick"/>
<Button
android:id="@+id/ya_switch_account_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/ya_submit_role_data_bt"
android:background="@drawable/public_sdk_self_ya_bt_selector"
android:onClick="yaOnClick" />
<Button
android:id="@+id/forum_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/public_sdk_self_ya_bt_selector"
android:onClick="yaOnClick" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/public_sdk_self_sdk_login_bg"
android:layout_height="match_parent" >
<Button
android:id="@+id/ya_login_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="28dp"
android:layout_marginTop="21dp"
android:background="@drawable/public_sdk_self_ya_login_bt_selector"
android:onClick="yaOnClick" />
<Button
android:id="@+id/ya_enter_game_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/ya_login_bt"
android:layout_below="@+id/ya_login_bt"
android:layout_marginTop="28dp"
android:background="@drawable/public_sdk_self_ya_login_bt_selector"
android:onClick="yaOnClick"/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">SDK_Demo</string>
</resources>
package com.youai.foolsdk.demo;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.gzyouai.fengniao.sdk.framework.PoolExitDialogListener;
import com.gzyouai.fengniao.sdk.framework.PoolExitListener;
import com.gzyouai.fengniao.sdk.framework.PoolExpansionListener;
import com.gzyouai.fengniao.sdk.framework.PoolLoginInfo;
import com.gzyouai.fengniao.sdk.framework.PoolLoginListener;
import com.gzyouai.fengniao.sdk.framework.PoolLogoutListener;
import com.gzyouai.fengniao.sdk.framework.PoolPayInfo;
import com.gzyouai.fengniao.sdk.framework.PoolPayListener;
import com.gzyouai.fengniao.sdk.framework.PoolReport;
import com.gzyouai.fengniao.sdk.framework.PoolRoleInfo;
import com.gzyouai.fengniao.sdk.framework.PoolRoleListener;
import com.gzyouai.fengniao.sdk.framework.PoolSDKCallBackListener;
import com.gzyouai.fengniao.sdk.framework.PoolSDKCode;
import com.gzyouai.fengniao.sdk.framework.PoolSdkHelper;
import com.gzyouai.fengniao.sdk.framework.PoolSdkLog;
public class AppActivity extends Activity {
private Button yaLoginBt;
private Button yaEnterGameBt;
private Button yaPayBt;
private Button yaSubmitRoleDataBt;
private Button yaChannelCenter;
private Button yaSwitchAccountBt;
private Button forumBt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int layoutId = getResources().getIdentifier(
"public_sdk_self_game_login", "layout", getPackageName());
setContentView(layoutId);
initLoginView();
PoolSdkLog.setIsShowLog(true);//显示PoolSDK log
PoolSdkHelper.init(this, new PoolSDKCallBackListener() {
@Override
public void poolSdkCallBack(int code, String msg) {
// TODO Auto-generated method stub
switch (code) {
case PoolSDKCode.POOLSDK_INIT_SUCCESS://初始化成功
PoolSdkLog.logInfo("游戏中POOLSDK_INIT_SUCCESS");
login();
break;
case PoolSDKCode.POOLSDK_INIT_FAIL:
break;
default:
break;
}
}
});
//注销账号监听(在SDK账号注销时回调通知,游戏可在此处理切换账号逻辑)
PoolSdkHelper.setLogoutCallback(new PoolLogoutListener() {
@Override
public void onLogoutSuccess() {
// TODO: 此处处理SDK登出的逻辑
login();
PoolSdkLog.logInfo("游戏中logoutSuccess");
}
});
}
@Override
public void onStart() {
super.onStart();
PoolSdkHelper.onStart();
}
@Override
public void onStop() {
super.onStop();
PoolSdkHelper.onStop();
}
@Override
public void onResume() {
super.onResume();
PoolSdkHelper.onResume();
}
@Override
public void onPause() {
super.onPause();
PoolSdkHelper.onPause();
}
@Override
public void onRestart() {
super.onRestart();
PoolSdkHelper.onRestart();
}
@Override
public void onDestroy() {
super.onDestroy();
PoolSdkHelper.onDestroy();
}
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
PoolSdkHelper.onNewIntent(intent);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
PoolSdkHelper.onActivityResult(requestCode, resultCode, data);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged(newConfig);
PoolSdkHelper.onConfigurationChanged(newConfig);
}
@Override
public boolean dispatchKeyEvent(KeyEvent pKeyEvent) {
if (pKeyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK
&& pKeyEvent.getAction() == KeyEvent.ACTION_DOWN) {
if (PoolSdkHelper.hasExitDialog()) {//判断SDK是否含有退出框
PoolSdkHelper.showExitDialog(new PoolExitDialogListener() {
@Override
public void onDialogResult(int code, String msg) {
// TODO Auto-generated method stub
switch (code) {
case PoolSDKCode.EXIT_SUCCESS:// 退出成功游戏处理自己退出逻辑
finish();
break;
case PoolSDKCode.EXIT_CANCEL://取消退出
break;
default:
break;
}
}
});
} else {
// TODO: 调用游戏的退出界面
showGameExitTips();
}
return false;
}
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 initLoginView() {
int ya_login_bt = getRedIdByName("ya_login_bt", "id");// getResources().getIdentifier("ya_login_bt",
// "id",
// getPackageName());
yaLoginBt = (Button) findViewById(ya_login_bt);
yaLoginBt.setText("登录");
yaEnterGameBt = (Button) findViewById(getRedIdByName(
"ya_enter_game_bt", "id"));
yaEnterGameBt.setText("进入游戏");
}
private void initGameView() {
yaPayBt = (Button) findViewById(getRedIdByName("ya_pay_bt", "id"));
yaPayBt.setText("支付");
yaSubmitRoleDataBt = (Button) findViewById(getRedIdByName(
"ya_submit_role_data_bt", "id"));
yaSubmitRoleDataBt.setText("提交角色数据");
yaChannelCenter = (Button) findViewById(getRedIdByName(
"ya_channel_center", "id"));
yaChannelCenter.setText("渠道中心");
yaSwitchAccountBt = (Button) findViewById(getRedIdByName(
"ya_switch_account_bt", "id"));
yaSwitchAccountBt.setText("切换账号");
forumBt = (Button)findViewById(getRedIdByName("forum_bt", "id"));
forumBt.setText("打开论坛");
PoolSdkLog.logError("" + yaPayBt + "yachannel:" + yaChannelCenter);
}
public void yaOnClick(View view) {
if (view == yaLoginBt) {
login();
} else if (view == yaEnterGameBt) {
setContentView(getRedIdByName("public_sdk_self_game", "layout"));// (R.layout.game);
initGameView();
PoolReport.reportEnterGame("chufan", 11, "201");
} else if (view == yaPayBt) {
pay();
} else if (view == yaSubmitRoleDataBt) {
submitRoleData();
} else if (view == yaChannelCenter) {
channelCenter();
} else if (view == yaSwitchAccountBt) {
switchAccount();
}else if(view == forumBt){
openForum();
}
}
private void openForum(){
Toast.makeText(this, "打开论坛", Toast.LENGTH_SHORT).show();
PoolSdkHelper.openForum();
}
private void login() {
PoolSdkHelper.login("登录自定义字段", new PoolLoginListener() {
@Override
public void onLoginSuccess(PoolLoginInfo poolLoginInfo) {
String userType = poolLoginInfo.getUserType();
String timestamp = poolLoginInfo.getTimestamp();
String serverSign = poolLoginInfo.getServerSign();
String openId = poolLoginInfo.getOpenID();
// TODO: 把以上信息发送给游戏服务端做登录校验,需要其他信息请从poolLoginInfo对象中获取
System.out.println("登录成功 userType = " + userType
+ "; timestamp = " + timestamp + "; serverSign = "
+ serverSign + "; openId = " + openId);
}
@Override
public void onLoginFailed(String errorMsg) {
System.out.println("登录失败 = " + errorMsg);
}
});
}
/**
* 充值接口
*/
private void pay() {
PoolPayInfo poolPayInfo = new PoolPayInfo();
/********************************************
* 以下所有字段都是必填项
*/
// 设置充值金额,单位“元”
poolPayInfo.setAmount("1");
// 服务器id
poolPayInfo.setServerID("8");
// 服务器名
poolPayInfo.setServerName("我是服务器名");
// 角色id
poolPayInfo.setRoleID("123456");
// 角色名
poolPayInfo.setRoleName("我是角色名");
// 角色等级
poolPayInfo.setRoleLevel("10");
// 商品ID
poolPayInfo.setProductID("1");
// 商品名称
poolPayInfo.setProductName("金币");
// 商品描述
poolPayInfo.setProductDesc("购买金币");
// 兑换比例
poolPayInfo.setExchange("10");
// 自定义参数
poolPayInfo.setCustom("我是自定义参数");
PoolSdkHelper.pay(poolPayInfo, new PoolPayListener() {
@Override
public void onPaySuccess(String paramCustom) {
System.out.println("支付成功 = " + paramCustom);
}
@Override
public void onPayFailed(String paramCustom, String errorMsg) {
System.out.println("支付失败 = " + paramCustom + "; errorMsg = "
+ errorMsg);
}
});
}
/**
* 提交角色数据 该接口需要在3个地方调用
*
* 1、登录游戏主场景 2、创建角色 3、角色升级
*/
private void submitRoleData() {
/********************************************
* 以下所有字段都是必填项
*/
PoolRoleInfo poolRoleInfo = new PoolRoleInfo();
poolRoleInfo.setRoleID("123456");
poolRoleInfo.setRoleLevel("10");
poolRoleInfo.setRoleSex("0");
poolRoleInfo.setRoleName("我是角色名");
poolRoleInfo.setServerID("1");
poolRoleInfo.setServerName("我是服务器名");
poolRoleInfo.setCustom(System.currentTimeMillis()/1000+"");//游戏创建角色时间 以秒为单位
poolRoleInfo.setCallType(PoolRoleInfo.Type_EnterGame);//1、登录游戏主场景 2、创建角色 3、角色升级
// poolRoleInfo.setCallType(PoolRoleInfo.Type_CreateRole);
// poolRoleInfo.setCallType(PoolRoleInfo.Type_RoleUpgrade);
PoolSdkHelper.submitRoleData(poolRoleInfo, new PoolRoleListener() {
@Override
public void onRoleDataSuccess(String paramCustom) {
System.out.println("提交角色数据成功 = " + paramCustom);
}
});
}
/**
* 用户中心
*
* 游戏方先调用PoolSDKHelper.hasChannelCenter()获取是否有用户中心,
* 如果有的话,游戏中需要添加按钮,点击按钮调用PoolSDKHelper.openChannelCenter();
* 如果没有,则不需要显示按钮,也不用调用下面的接口
*/
private void channelCenter() {
PoolSdkHelper.openChannelCenter();
}
/**
* 切换帐号(使用用户中心中的切换账号)
*/
private void switchAccount() {
boolean hasChannelCenter = PoolSdkHelper.hasChannelCenter();
if(hasChannelCenter){
PoolSdkHelper.openChannelCenter();//打开用户中心
}else{//如果没有用户中心 游戏自己处理切换账号逻辑
setContentView(getRedIdByName("public_sdk_self_game_login",
"layout"));// (R.layout.game_login);
initLoginView();
}
}
/**
* 扩展接口
*/
private void expansionInterface() {
PoolSdkHelper.expansionInterface("自定义参数", new PoolExpansionListener() {
@Override
public void onSuccess(String paramCustom) {
}
});
}
}
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type