Commit d295d09fc837e1a770d3f953dad06b22efd3dbe1

Authored by 赵康
Exists in master

Merge branch 'master' of http://123.59.74.8/document/gumptech-document

Showing 7 changed files Inline Diff

android/GameSDKRelease/libs/GameSDK_v3.3.4_proguard.jar
No preview for this file type
android/GameSDKRelease/libs/GameSDK_v3.3.5_proguard.jar
No preview for this file type
android/GameSDKRelease/res/layout/pay_container.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="match_parent" 3 android:layout_width="match_parent"
4 android:layout_height="match_parent" 4 android:layout_height="match_parent"
5 android:background="@color/payment_common_bg" 5 android:background="@color/payment_common_bg"
6 android:orientation="vertical" > 6 android:orientation="vertical" >
7 7
8 <LinearLayout 8 <ProgressBar
9 android:id="@+id/container" 9 android:id="@+id/loading_prog"
10 style="@android:style/Widget.ProgressBar.Horizontal"
10 android:layout_width="match_parent" 11 android:layout_width="match_parent"
11 android:layout_height="wrap_content" 12 android:layout_height="2dp" />
12 android:orientation="vertical" > 13
13 14 <WebView
14 </LinearLayout> 15 android:id="@+id/mycard_web"
16 android:layout_width="fill_parent"
17 android:layout_height="fill_parent" />
18
19 <!-- <LinearLayout -->
20 <!-- android:id="@+id/container" -->
21 <!-- android:layout_width="match_parent" -->
22 <!-- android:layout_height="wrap_content" -->
23 <!-- android:orientation="vertical" > -->
24 <!-- </LinearLayout> -->
15 25
16 </LinearLayout> 26 </LinearLayout>
android/GameSDKSample/project.properties
1 # This file is automatically generated by Android Tools. 1 # This file is automatically generated by Android Tools.
2 # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 2 # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 # 3 #
4 # This file must be checked in Version Control Systems. 4 # This file must be checked in Version Control Systems.
5 # 5 #
6 # To customize properties used by the Ant build system edit 6 # To customize properties used by the Ant build system edit
7 # "ant.properties", and override values to adapt the script to your 7 # "ant.properties", and override values to adapt the script to your
8 # project structure. 8 # project structure.
9 # 9 #
10 # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 10 # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 11 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 12
13 # Project target. 13 # Project target.
14 14
15 target=android-22 15 target=android-21
16 android.library.reference.1=../GameSDKRelease 16 android.library.reference.1=../../../../gamesdk/GameSDK
17 17
android/GameSDKSample/src/com/gumptech/loginsdk/sample/MainActivity.java
1 package com.gumptech.loginsdk.sample; 1 package com.gumptech.loginsdk.sample;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.content.Context; 4 import android.content.Context;
5 import android.os.Bundle; 5 import android.os.Bundle;
6 import android.text.ClipboardManager; 6 import android.text.ClipboardManager;
7 import android.util.Log; 7 import android.util.Log;
8 import android.view.View; 8 import android.view.View;
9 import android.widget.Button; 9 import android.widget.Button;
10 import android.widget.TextView; 10 import android.widget.TextView;
11 import android.widget.Toast; 11 import android.widget.Toast;
12 12
13 import com.gumptech.sdk.GumpPreference; 13 import com.gumptech.sdk.GumpPreference;
14 import com.gumptech.sdk.GumpSDK; 14 import com.gumptech.sdk.GumpSDK;
15 import com.gumptech.sdk.bean.GumpUser; 15 import com.gumptech.sdk.bean.GumpUser;
16 import com.gumptech.sdk.bean.PurchaseResult; 16 import com.gumptech.sdk.bean.PurchaseResult;
17 import com.gumptech.sdk.callback.InitializeCallback; 17 import com.gumptech.sdk.callback.InitializeCallback;
18 import com.gumptech.sdk.callback.LoginStateListener; 18 import com.gumptech.sdk.callback.LoginStateListener;
19 import com.gumptech.sdk.callback.PurchaseCallback; 19 import com.gumptech.sdk.callback.PurchaseCallback;
20 import com.gumpsdk.wuruid.R; 20 import com.gumpsdk.wuruid.R;
21 21
22 public class MainActivity extends Activity implements PurchaseCallback{ 22 public class MainActivity extends Activity implements PurchaseCallback{
23 23
24 private static final String TAG = "MainActivity"; 24 private static final String TAG = "MainActivity";
25 25
26 private TextView tvVersion; 26 private TextView tvVersion;
27 private TextView userInfo; 27 private TextView userInfo;
28 28
29 private Button btnLoginOrLogout; 29 private Button btnLoginOrLogout;
30 30
31 private String appId = "10022"; 31 private String appId = "10022";
32 private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; 32 private String appKey = "93a27b0bd99bac3e68a440b48aa421ab";
33 33 private String sessionKey;
34 @Override 34
35 protected void onCreate(Bundle savedInstanceState) { 35 @Override
36 super.onCreate(savedInstanceState); 36 protected void onCreate(Bundle savedInstanceState) {
37 setContentView(R.layout.activity_main); 37 super.onCreate(savedInstanceState);
38 tvVersion = (TextView) findViewById(R.id.version); 38 setContentView(R.layout.activity_main);
39 userInfo = (TextView) findViewById(R.id.user_info); 39 tvVersion = (TextView) findViewById(R.id.version);
40 btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); 40 userInfo = (TextView) findViewById(R.id.user_info);
41 btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { 41 btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout);
42 42 btnLoginOrLogout.setOnClickListener(new View.OnClickListener() {
43 @Override 43
44 public void onClick(View v) { 44 @Override
45 if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) 45 public void onClick(View v) {
46 GumpSDK.start(MainActivity.this); 46 if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0)
47 else 47 GumpSDK.start(MainActivity.this);
48 GumpSDK.logout(MainActivity.this); 48 else
49 } 49 GumpSDK.logout(MainActivity.this);
50 }); 50 }
51 findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { 51 });
52 52 findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() {
53 @Override 53
54 public void onClick(View v) { 54 @Override
55 Bundle payInfo = new Bundle(); 55 public void onClick(View v) {
56 payInfo.putString("nick", "thi"); 56 Bundle payInfo = new Bundle();
57 payInfo.putString("product", "元宝"); 57 payInfo.putString("nick", "thi");
58 payInfo.putFloat("amount", 0.0f); 58 payInfo.putString("product", "元宝");
59 payInfo.putString("extraInfo", "This is demo!"); 59 payInfo.putFloat("amount", 0.0f);
60 payInfo.putString("serverId", "5025"); 60 payInfo.putString("extraInfo", "This is demo!");
61 GumpSDK.pay(MainActivity.this, payInfo, "7798753", MainActivity.this); 61 payInfo.putString("serverId", "100");
62 } 62 payInfo.putString("sessionKey", sessionKey);
63 }); 63 GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this);
64 /** 64 }
65 * 设置否是开启debug模式 65 });
66 */ 66 /**
67 GumpSDK.setDebugState(true); 67 * 设置否是开启debug模式
68 /** 68 */
69 * 设置是否启用facebook登录 69 GumpSDK.setDebugState(false);
70 */ 70 /**
71 GumpSDK.setFBEnable(true); 71 * 设置是否启用facebook登录
72 /** 72 */
73 * 设置是否启用Vk登录 73 GumpSDK.setFBEnable(true);
74 */ 74 /**
75 GumpSDK.setVKEnable(true); 75 * 设置是否启用Vk登录
76 /** 76 */
77 * 设置屏幕方向 77 GumpSDK.setVKEnable(true);
78 */ 78 /**
79 GumpSDK.setScreenLandscape(false); 79 * 设置屏幕方向
80 /** 80 */
81 * 设置用户登录状态监听器 81 GumpSDK.setScreenLandscape(true);
82 */ 82 /**
83 GumpSDK.setUserStateListener(new LoginStateListener() { 83 * 设置用户登录状态监听器
84 @Override 84 */
85 public void onLoginSuccess(GumpUser user) { 85 GumpSDK.setUserStateListener(new LoginStateListener() {
86 ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); 86 @Override
87 cm.setText(user.getSessionKey()); 87 public void onLoginSuccess(GumpUser user) {
88 88 ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
89 String userType=null; 89 cm.setText(user.getSessionKey());
90 switch(user.getAccountType()){ 90 sessionKey = user.getSessionKey();
91 case GumpPreference.ACCOUNT_TYPE_FB: 91 String userType=null;
92 userType = "Facebook登录"; 92 switch(user.getAccountType()){
93 break; 93 case GumpPreference.ACCOUNT_TYPE_FB:
94 case GumpPreference.ACCOUNT_TYPE_QUICK_REG: 94 userType = "Facebook登录";
95 userType = "快速登录"; 95 break;
96 break; 96 case GumpPreference.ACCOUNT_TYPE_QUICK_REG:
97 case GumpPreference.ACCOUNT_TYPE_REG: 97 userType = "快速登录";
98 userType = "gump注册用户"; 98 break;
99 break; 99 case GumpPreference.ACCOUNT_TYPE_REG:
100 case GumpPreference.ACCOUNT_TYPE_VK: 100 userType = "gump注册用户";
101 userType = "vk登录"; 101 break;
102 break; 102 case GumpPreference.ACCOUNT_TYPE_VK:
103 } 103 userType = "vk登录";
104 userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType()+") "+userType + "\n sessionKey:" + user.getSessionKey()); 104 break;
105 btnLoginOrLogout.setText("Logout"); 105 }
106 btnLoginOrLogout.setTag(1); 106 userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType()+") "+userType + "\n sessionKey:" + user.getSessionKey());
107 } 107 btnLoginOrLogout.setText("Logout");
108 108 btnLoginOrLogout.setTag(1);
109 @Override 109 }
110 public void onLoginFailed(int code, String msg) { 110
111 userInfo.setText(msg); 111 @Override
112 Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); 112 public void onLoginFailed(int code, String msg) {
113 } 113 userInfo.setText(msg);
114 114 Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show();
115 @Override 115 }
116 public void onLoginCanceled() { 116
117 Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); 117 @Override
118 } 118 public void onLoginCanceled() {
119 119 Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show();
120 @Override 120 }
121 public void onLogout() { 121
122 btnLoginOrLogout.setText("Login"); 122 @Override
123 btnLoginOrLogout.setTag(0); 123 public void onLogout() {
124 userInfo.setText("User is logout"); 124 btnLoginOrLogout.setText("Login");
125 } 125 btnLoginOrLogout.setTag(0);
126 }); 126 userInfo.setText("User is logout");
127 /** 127 }
128 * 初始化sdk 128 });
129 */ 129 /**
130 GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { 130 * 初始化sdk
131 @Override 131 */
132 public void initComplete(int result) { 132 GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() {
133 if (result == GumpSDK.CODE.OK) { 133 @Override
134 btnLoginOrLogout.setEnabled(true); 134 public void initComplete(int result) {
135 } 135 if (result == GumpSDK.CODE.OK) {
136 } 136 btnLoginOrLogout.setEnabled(true);
137 }); 137 }
138 138 }
139 139 });
140 tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); 140
141 } 141
142 142 tvVersion.setText("SDK Version:" + GumpSDK.getVersion());
143 @Override 143 }
144 public void onPurchaseCompleted(PurchaseResult result) { 144
145 Log.i(TAG,"purchase completed"); 145 @Override
146 } 146 public void onPurchaseCompleted(PurchaseResult result) {
147 147 Log.i(TAG,"purchase completed");
148 @Override 148 }
149 public void onPurchaseError(int code, String msg) { 149
150 Log.i(TAG,"purchase error"); 150 @Override
151 } 151 public void onPurchaseError(int code, String msg) {
152 152 Log.i(TAG,"purchase error");
153 @Override 153 }
154 public void onPurchaseCanceled() { 154
155 Log.i(TAG,"purchase canceled"); 155 @Override
156 } 156 public void onPurchaseCanceled() {
157 } 157 Log.i(TAG,"purchase canceled");
158 }
159 }
158 160
doc/AndroidDocument.md
1 # Gump Android SDK使用文档 1 # Gump Android SDK使用文档
2 2
3 3
4 接入手册 4 接入手册
5 V 3.3.4 5 V 3.3.5
6 2016年01月22日 6 2016年03月04日
7 7
8 快速入口: 8 快速入口:
9 [支付部分服务端回调文档](http://git.letsgame.mobi/document/gumptech-document/blob/master/doc/ServerDocument.md) 9 [支付部分服务端回调文档](http://git.letsgame.mobi/document/gumptech-document/blob/master/doc/ServerDocument.md)
10 10
11 ## 目录 11 ## 目录
12 12
13 * [第一章 接入指南](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#) 13 * [第一章 接入指南](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#)
14 - [1. 导入资源工程](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#1) 14 - [1. 导入资源工程](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#1)
15 - [2. 添加资源工程](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#2) 15 - [2. 添加资源工程](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#2)
16 - [3. 代码实现](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#3) 16 - [3. 代码实现](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#3)
17 > [1.修改AndroidManifest.xml文件](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#1-androidmanifest-xml) 17 > [1.修改AndroidManifest.xml文件](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#1-androidmanifest-xml)
18 > [2.向Gump平台索要游戏ID(AppID),完成代码接入](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#2-gump-id-gid) 18 > [2.向Gump平台索要游戏ID(AppID),完成代码接入](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#2-gump-id-gid)
19 * [第二章 常见问题](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#) 19 * [第二章 常见问题](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#)
20 - [问题1: 如何避免混淆对SDK的影响?](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#1-sdk) 20 - [问题1: 如何避免混淆对SDK的影响?](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#1-sdk)
21 - [问题2:后台已经配置ok的情况下,支付列表仍然为空或登录总是出错?](http://git.letsgame.mobi/document/gumptech-document/blob/master/doc/AndroidDocument.md#2-ok) 21 - [问题2:后台已经配置ok的情况下,支付列表仍然为空或登录总是出错?](http://git.letsgame.mobi/document/gumptech-document/blob/master/doc/AndroidDocument.md#2-ok)
22 22
23 23
24 24
25 25
26 ## 第一章 接入指南 26 ## 第一章 接入指南
27 配置环境 27 配置环境
28 28
29 本接口API 适用于Android2.2以上各版本Android平台。 29 本接口API 适用于Android2.2以上各版本Android平台。
30 ### 1. 导入资源工程 30 ### 1. 导入资源工程
31 1.将GameSDK资源工程拷贝到工作空间,在eclipse中的导航栏右键弹出如图1画面,选择Import导入资源工程,如图1. 31 1.将GameSDK资源工程拷贝到工作空间,在eclipse中的导航栏右键弹出如图1画面,选择Import导入资源工程,如图1.
32 注意:本sdk需要使用Facebook sdk for android 4.4.1实现fb登录,请自行导入Facebook SDK 32 注意:本sdk需要使用Facebook sdk for android 4.4.1实现fb登录,请自行导入Facebook SDK
33 注意:本sdk需要使用VK sdk for android 1.5.4实现vk登录,请自行导入此sdk;若不接入vk登录,可以不导入此sdk并忽略vk相关的配置 33 注意:本sdk需要使用VK sdk for android 1.5.4实现vk登录,请自行导入此sdk;若不接入vk登录,可以不导入此sdk并忽略vk相关的配置
34 34
35 ![](images/1.png) 35 ![](images/1.png)
36 图1 36 图1
37 37
38 2.导入工程后,右键此工程,在Properties->Android中选中此工程为library工程(勾选红色方框标识处)如图2。 38 2.导入工程后,右键此工程,在Properties->Android中选中此工程为library工程(勾选红色方框标识处)如图2。
39 ![](images/2.png) 39 ![](images/2.png)
40 图 2 40 图 2
41 ### 2. 添加资源工程 41 ### 2. 添加资源工程
42 添加资源工程为游戏项目的 library。右键游戏项目,在Properties->Android中点击Add添加资源工程为项目工程的library,结果如图3。 42 添加资源工程为游戏项目的 library。右键游戏项目,在Properties->Android中点击Add添加资源工程为项目工程的library,结果如图3。
43 ![](images/3.png) 43 ![](images/3.png)
44 图 3 44 图 3
45 45
46 46
47 注意:如果ADT版本低于14,ADT不支持jar包自动引入,请手动拷贝libs到您的工作 47 注意:如果ADT版本低于14,ADT不支持jar包自动引入,请手动拷贝libs到您的工作
48 空间。 48 空间。
49 49
50 Eclipse查看ADT版本号的方法: 50 Eclipse查看ADT版本号的方法:
51 Help==>About Eclips点击Android对应的图标就可以查看版本了. 51 Help==>About Eclips点击Android对应的图标就可以查看版本了.
52 如图,红色框部分就是ADT版本号。 52 如图,红色框部分就是ADT版本号。
53 53
54 ![](images/4.png) 54 ![](images/4.png)
55 55
56 56
57 ### 3. 代码实现 57 ### 3. 代码实现
58 #### 1、 修改AndroidManifest.xml文件 58 #### 1、 修改AndroidManifest.xml文件
59 首先添加必要的权限,如下所示: 59 首先添加必要的权限,如下所示:
60 60
61 <uses-permission android:name="android.permission.INTERNET" /> 61 <uses-permission android:name="android.permission.INTERNET" />
62 <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 62 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
63 <uses-permission android:name="android.permission.BLUETOOTH" /> 63 <uses-permission android:name="android.permission.BLUETOOTH" />
64 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 64 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
65 <uses-permission android:name="android.permission.WRITE_SETTINGS"/> 65 <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
66 <uses-permission android:name="android.permission.GET_ACCOUNTS"/> 66 <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
67 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 67 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
68 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 68 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
69 <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> 69 <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
70 <uses-permission android:name="android.permission.SEND_SMS"/> 70 <uses-permission android:name="android.permission.SEND_SMS"/>
71 71
72 <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> 72 <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. -->
73 <uses-permission android:name="com.android.vending.BILLING" /> 73 <uses-permission android:name="com.android.vending.BILLING" />
74 74
75 其次注册相应的Activity,具体如下: 75 其次注册相应的Activity,具体如下:
76 76
77 <activity 77 <activity
78 android:name="com.gumptech.sdk.ContainerActivity" 78 android:name="com.gumptech.sdk.ContainerActivity"
79 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" 79 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout"
80 android:windowSoftInputMode="stateAlwaysHidden|adjustPan" 80 android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
81 android:theme="@style/Theme.TransparentWin" > 81 android:theme="@style/Theme.TransparentWin" >
82 </activity> 82 </activity>
83 <activity 83 <activity
84 android:name="com.gumptech.sdk.PaymentActivity" 84 android:name="com.gumptech.sdk.PaymentActivity"
85 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" 85 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout"
86 android:theme="@android:style/Theme.Translucent.NoTitleBar" > 86 android:theme="@android:style/Theme.Translucent.NoTitleBar" >
87 </activity> 87 </activity>
88 <activity 88 <activity
89 android:name="com.gumptech.sdk.ExchangeWindow" 89 android:name="com.gumptech.sdk.ExchangeWindow"
90 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" 90 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout"
91 android:theme="@style/Theme.WinForExchange" > 91 android:theme="@style/Theme.WinForExchange" >
92 </activity> 92 </activity>
93 93
94 <service android:name="com.gumptech.sdk.PushService" > 94 <service android:name="com.gumptech.sdk.PushService" >
95 </service> 95 </service>
96 <!-- facebook --> 96 <!-- facebook -->
97 <activity 97 <activity
98 android:name="com.facebook.FacebookActivity" 98 android:name="com.facebook.FacebookActivity"
99 android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" 99 android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
100 android:label="@string/app_name" 100 android:label="@string/app_name"
101 android:theme="@android:style/Theme.Translucent.NoTitleBar" /> 101 android:theme="@android:style/Theme.Translucent.NoTitleBar" />
102 <!-- vk登录使用,若不接入vk,不需配置 --> 102 <!-- vk登录使用,若不接入vk,不需配置 -->
103 <activity android:name="com.vk.sdk.VKOpenAuthActivity" /> 103 <activity android:name="com.vk.sdk.VKOpenAuthActivity" />
104 <activity 104 <activity
105 android:name="com.vk.sdk.VKServiceActivity" 105 android:name="com.vk.sdk.VKServiceActivity"
106 android:label="ServiceActivity" 106 android:label="ServiceActivity"
107 android:theme="@style/VK.Transparent" /> 107 android:theme="@style/VK.Transparent" />
108 108
109 109
110 #### 2、 向Gump平台索要游戏ID(AppID),完成代码接入 110 #### 2、 向Gump平台索要游戏ID(AppID),完成代码接入
111 正式开始接入逻辑代码前,先介绍下一些附加配置,以方便代码接入 111 正式开始接入逻辑代码前,先介绍下一些附加配置,以方便代码接入
112 112
113 *横竖屏控制,默认为横屏,参数为false即为竖屏 113 *横竖屏控制,默认为横屏,参数为false即为竖屏
114 114
115 GumpSDK.setScreenLandscape(true); 115 GumpSDK.setScreenLandscape(true);
116 *debug模式设置 116 *debug模式设置
117 117
118 GumpSDK.setDebugState(true); 118 GumpSDK.setDebugState(true);
119 119
120 *设置是否启用Facebook登录和VK登录 120 *设置是否启用Facebook登录和VK登录
121 121
122 GumpSDK.setFBEnable(true); 122 GumpSDK.setFBEnable(true);
123 GumpSDK.setVKEnable(true); 123 GumpSDK.setVKEnable(true);
124 1.调用GumpSDK前需要执行初始化。 124 1.调用GumpSDK前需要执行初始化。
125 125
126 若不需要分渠道 126 若不需要分渠道
127 127
128 GumpSDK.init(Context,Appid, Appkey,InitializeCallback); 128 GumpSDK.init(Context,Appid, Appkey,InitializeCallback);
129 如果需要定义渠道,必须使用如下方法 129 如果需要定义渠道,必须使用如下方法
130 130
131 GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); 131 GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback);
132 132
133 InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 133 InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败
134 134
135 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 135 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数
136 136
137 GumpSDK.start(Activity); 137 GumpSDK.start(Activity);
138 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: 138 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下:
139 139
140 GumpSDK.setUserStateListener(new LoginStateListener() { 140 GumpSDK.setUserStateListener(new LoginStateListener() {
141 @Override 141 @Override
142 public void onLoginSuccess(GumpUser gumpUser) { 142 public void onLoginSuccess(GumpUser gumpUser) {
143 //登录成功,用户信息包含在GumpUser对象里 143 //登录成功,用户信息包含在GumpUser对象里
144 } 144 }
145 145
146 @Override 146 @Override
147 public void onLoginFailed(int code, String msg) { 147 public void onLoginFailed(int code, String msg) {
148 //登录出错,根据错误码和信息判断错误类型 148 //登录出错,根据错误码和信息判断错误类型
149 Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); 149 Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show();
150 } 150 }
151 151
152 @Override 152 @Override
153 public void onLoginCanceled() { 153 public void onLoginCanceled() {
154 //用户取消登录 154 //用户取消登录
155 Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); 155 Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show();
156 } 156 }
157 157
158 @Override 158 @Override
159 public void onLogout() { 159 public void onLogout() {
160 //用户登出 160 //用户登出
161 161
162 } 162 }
163 }); 163 });
164 164
165 如上成功登录后收到的GumpUser对象包含以下信息 165 如上成功登录后收到的GumpUser对象包含以下信息
166 166
167 gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! 167 gumpUser.getUid();//获取用户的userid,此Id标识唯一用户!
168 gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 168 gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取
169 gumpUser.getSessionKey();//登录的sesionKey 169 gumpUser.getSessionKey();//登录的sesionKey
170 170
171 171
172 3.支付功能 172 3.支付功能
173 1)使用gump通行证登录,其中除nick外所有参数为必传参数 173 1)使用gump通行证登录,其中除nick和roleId外所有参数为必传参数
174 174
175 Bundle payInfo = new Bundle(); 175 Bundle payInfo = new Bundle();
176 payInfo.putString("nick", "thi"); 176 payInfo.putString("nick", "thi");
177 payInfo.putString("product", "元宝"); 177 payInfo.putString("product", "元宝");
178 payInfo.putFloat("amount", 40.0f); 178 payInfo.putFloat("amount", 40.0f);
179 payInfo.putString("extraInfo", "This is demo!"); 179 payInfo.putString("extraInfo", "This is demo!");
180 payInfo.putString("serverId", "B4003"); 180 payInfo.putString("serverId", "B4003");
181 payInfo.putString("roleId", "10010"); 181 payInfo.putString("roleId", "10010");
182 payInfo.putString("sessionKey","sessionkey");
182 GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); 183 GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback);
183 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick外所有字段必须全部包含 184 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick和roleId外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey
184 2)未使用gump通行证登录,需要传入用户id 185 2)未使用gump通行证登录,需要传入用户id,同时sessionKey不再需要
185 186
186 Bundle payInfo = new Bundle(); 187 Bundle payInfo = new Bundle();
187 payInfo.putString("nick", "thi"); 188 payInfo.putString("nick", "thi");
188 payInfo.putString("product", "元宝"); 189 payInfo.putString("product", "元宝");
189 payInfo.putFloat("amount", 40.0f); 190 payInfo.putFloat("amount", 40.0f);
190 payInfo.putString("extraInfo", "This is demo!"); 191 payInfo.putString("extraInfo", "This is demo!");
191 payInfo.putString("serverId", "B4003"); 192 payInfo.putString("serverId", "B4003");
192 payInfo.putString("roleId", "10010"); 193 payInfo.putString("roleId", "10010");
193 GumpSDK.pay(MainActivity.this, payInfo,userId,PurchaseCallback); 194 GumpSDK.pay(MainActivity.this, payInfo,userId,PurchaseCallback);
194 195
195 PurchaseCallback为支付状态回调接口,此接口含有3个方法 196 PurchaseCallback为支付状态回调接口,此接口含有3个方法
196 197
197 @Override 198 @Override
198 public void onPurchaseCompleted(PurchaseResult result) { 199 public void onPurchaseCompleted(PurchaseResult result) {
199 Log.i(TAG,"purchase completed"); 200 Log.i(TAG,"purchase completed");
200 } 201 }
201 202
202 @Override 203 @Override
203 public void onPurchaseError(int code, String msg) { 204 public void onPurchaseError(int code, String msg) {
204 Log.i(TAG,"purchase error"); 205 Log.i(TAG,"purchase error");
205 } 206 }
206 207
207 @Override 208 @Override
208 public void onPurchaseCanceled() { 209 public void onPurchaseCanceled() {
209 Log.i(TAG,"purchase canceled"); 210 Log.i(TAG,"purchase canceled");
210 } 211 }
211 212
212 5.注销登录 213 5.注销登录
213 214
214 GumpSDK.logout(Activity); 215 GumpSDK.logout(Activity);
215 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序! 216 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!
216 ## 第二章 常见问题 217 ## 第二章 常见问题
217 ### 问题1: 如何避免混淆对SDK的影响? 218 ### 问题1: 如何避免混淆对SDK的影响?
218 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java 219 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java
219 类,导致SDK无法正常工作,解决方法如下: 220 类,导致SDK无法正常工作,解决方法如下:
220 Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 221 Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上
221 222
222 -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable 223 -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable
223 -keep public class * extends android.app.Service 224 -keep public class * extends android.app.Service
224 -keep public class com.google.vending.licensing.ILicensingService 225 -keep public class com.google.vending.licensing.ILicensingService
225 -keep public class com.android.vending.licensing.ILicensingService 226 -keep public class com.android.vending.licensing.ILicensingService
226 -keep class com.gumptech.sdk.view.* {*;} 227 -keep class com.gumptech.sdk.view.* {*;}
227 -keep class com.gumptech.sdk.web.* {*;} 228 -keep class com.gumptech.sdk.web.* {*;}
228 229
229 230
230 使得混淆的时候不会影响SDK的命名空间。 231 使得混淆的时候不会影响SDK的命名空间。
1 以下两个接口需要研发商提供,否则支付的时候会出现"获取支付信息失败"提示 1 以下两个接口需要研发商提供,否则支付的时候会出现"获取支付信息失败"提示
2 ---------------------------------- 2 ----------------------------------
3 接口请联系运营人员配置到Gump管理后台 3 接口请联系运营人员配置到Gump管理后台
4 4
5 5
6 第三方查询角色接口(需要研发商提供) 6 第三方查询角色接口(需要研发商提供)
7 ------------------------- 7 -------------------------
8 8
9 GumpTech调用过程如下: 9 GumpTech调用过程如下:
10 请求接口:queryRoleUrl的地址 10 请求接口:queryRoleUrl的地址
11 请求方式:post 11 请求方式:post
12 参数: 12 参数:
13 serverId servers参数json中的serverId的值 13 serverId servers参数json中的serverId的值
14 userId GumpTech用户id 14 userId GumpTech用户id
15 返回值: 15 返回值:
16 { 16 {
17 "userId":5104 17 "userId":5104
18 "roleId":5104 18 "roleId":5104
19 "roleName":"卡卡" 19 "roleName":"卡卡"
20 } 20 }
21 userId为GumpTech平台的用户id 21 userId为GumpTech平台的用户id
22 roleId为第三方平台的角色id 22 roleId为第三方平台的角色id
23 roleName为第三方平台的角色名字 23 roleName为第三方平台的角色名字
24 24
25 25
26 第三方查询区服列表接口(需要研发商提供) 26 第三方查询区服列表接口(需要研发商提供)
27 ------------------------- 27 -------------------------
28 28
29 29
30 Gump调用过程如下:querySeversUrl的地址 30 Gump调用过程如下:querySeversUrl的地址
31 31
32 请求方式:get方式 32 请求方式:get方式
33 参数:无 33 参数:无
34 返回值: 34 返回值:
35 35
36 字符串格式json串,如下: 36 字符串格式json串,如下:
37 [ 37 [
38 {"serverId":"s2", "serverName":"测试1"}, 38 {"serverId":"s2", "serverName":"测试1"},
39 {"serverId":"s2", "serverName":"测试1"} 39 {"serverId":"s2", "serverName":"测试1"}
40 ... 40 ...
41 ] 41 ]
42 42
43 43
44 充值成功通知第三方服务端接口 44 充值成功通知第三方服务端接口
45 ----------------------------- 45 -----------------------------
46 46
47 47
48 请参考[GumpTech服务端文档](http://git.letsgame.mobi/document/gumptech-document/blob/master/doc/ServerDocument.md) 48 请参考[GumpTech服务端文档](http://git.letsgame.mobi/document/gumptech-document/blob/master/doc/ServerDocument.md)
49 49
50 50
51 51
52 52
53 53
54 GumpTech页面支付(已集成到sdk中,可忽略) 54 GumpTech页面支付(已集成到sdk中,可忽略)
55 ----------------------- 55 -----------------------
56 56
57 接入使用方式: 57 接入使用方式:
58 ----------------------- 58 -----------------------
59 请使用浏览器方式嵌套GumpTech支付地址: 59 请使用浏览器方式嵌套GumpTech支付地址:
60 60
61 统一支付: http://api.gumptech.com/v2/p/index.do 61 统一支付: http://api.gumptech.com/v2/p/index.do
62 横版: http://api.gumptech.com/v2/wide/p/index.do 62 横版: http://api.gumptech.com/v2/wide/p/index.do
63
64 横版V3: http://api.gumptech.com/v3/wide/p/index.do(引入Gump币支付)
65
63 需要传入参数: 66 需要传入参数:
64 1. appId: 必选参数 接入前GumpTeck分配的应用id 67 1. appId: 必选参数 接入前GumpTeck分配的应用id
65 2. userId: 必选参数 GumpTech平台的用户id 68 2. userId: 必选参数 GumpTech平台的用户id
66 3. serverId: 必选参数 注意次参数为字符串,必须保证跟获取区服列表中serverId值保证一致 69 3. serverId: 必选参数 注意次参数为字符串,必须保证跟获取区服列表中serverId值保证一致
67 4. extraInfo: 必选参数 第三方自定义字段,字符200以内,原样回调给第三方。 70 4. extraInfo: 必选参数 第三方自定义字段,字符200以内,原样回调给第三方。
68 5. product: 必选参数 第三方传入,购买物品 71 5. product: 必选参数 第三方传入,购买物品
69 6. amount: 可选参数 第三方传入,购买物品所需要的金额(点数) 72 6. amount: 可选参数 第三方传入,购买物品所需要的金额(点数)
70 73
74 7.sessionKey: V3版本必选 登录获取的sessionKey,支付使用
75
71 以下参数需要在服务端配置,需要研发商联系接口人配置: 76 以下参数需要在服务端配置,需要研发商联系接口人配置:
72 1. queryRoleUrl: 支付页面显示服务器列表 参考【第三方查询角色接口】 77 1. queryRoleUrl: 支付页面显示服务器列表 参考【第三方查询角色接口】
73 2. querySeversUrl: 查询用户角色 格式参考【第三方查询区服列表接口】 78 2. querySeversUrl: 查询用户角色 格式参考【第三方查询区服列表接口】