Commit 19a7ec3f1b97915e30ca7b33ccf06c434f0158ff
1 parent
09d4c173fb
Exists in
master
sdk3.0.0更新使用web支付
Showing 1 changed file with 2 additions and 70 deletions Inline Diff
doc/AndroidDocument.md
1 | # Gump Android SDK使用文档 | 1 | # Gump Android SDK使用文档 |
2 | 2 | ||
3 | 3 | ||
4 | 接入手册 | 4 | 接入手册 |
5 | V 2.3.1 | 5 | V 2.3.1 |
6 | 2015年01月08日 | 6 | 2015年01月08日 |
7 | 7 | ||
8 | 快速入口: | 8 | 快速入口: |
9 | [支付部分服务端回调文档](http://git.letsgame.mobi/document/gumptech-document/blob/master/ServerDocument.md) | 9 | [支付部分服务端回调文档](http://git.letsgame.mobi/document/gumptech-document/blob/master/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(GID),完成代码接入](http://git.letsgame.mobi/document/gumptech-document/blob/master/AndroidDocument.md#2-gump-id-gid) | 18 | > [2.向Gump平台索要游戏ID(GID),完成代码接入](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.将LoginSDK资源工程拷贝到工作空间,在eclipse中的导航栏右键弹出如图1画面,选择Import导入资源工程,如图1. | 31 | 1.将LoginSDK资源工程拷贝到工作空间,在eclipse中的导航栏右键弹出如图1画面,选择Import导入资源工程,如图1. |
32 | 32 | ||
33 |  | 33 |  |
34 | 图1 | 34 | 图1 |
35 | 35 | ||
36 | 2.导入工程后,右键此工程,在Properties->Android中选中此工程为library工程(勾选红色方框标识处)如图2。 | 36 | 2.导入工程后,右键此工程,在Properties->Android中选中此工程为library工程(勾选红色方框标识处)如图2。 |
37 |  | 37 |  |
38 | 图 2 | 38 | 图 2 |
39 | ### 2. 添加资源工程 | 39 | ### 2. 添加资源工程 |
40 | 添加资源工程为游戏项目的 library。右键游戏项目,在Properties->Android中点击Add添加资源工程为项目工程的library,结果如图3。 | 40 | 添加资源工程为游戏项目的 library。右键游戏项目,在Properties->Android中点击Add添加资源工程为项目工程的library,结果如图3。 |
41 |  | 41 |  |
42 | 图 3 | 42 | 图 3 |
43 | 43 | ||
44 | 44 | ||
45 | 注意:如果ADT版本低于14,ADT不支持jar包自动引入,请手动拷贝libs到您的工作 | 45 | 注意:如果ADT版本低于14,ADT不支持jar包自动引入,请手动拷贝libs到您的工作 |
46 | 空间。 | 46 | 空间。 |
47 | 47 | ||
48 | Eclipse查看ADT版本号的方法: | 48 | Eclipse查看ADT版本号的方法: |
49 | Help==>About Eclips点击Android对应的图标就可以查看版本了. | 49 | Help==>About Eclips点击Android对应的图标就可以查看版本了. |
50 | 如图,红色框部分就是ADT版本号。 | 50 | 如图,红色框部分就是ADT版本号。 |
51 | 51 | ||
52 |  | 52 |  |
53 | 53 | ||
54 | 54 | ||
55 | ### 3. 代码实现 | 55 | ### 3. 代码实现 |
56 | #### 1、 修改AndroidManifest.xml文件 | 56 | #### 1、 修改AndroidManifest.xml文件 |
57 | 首先添加必要的权限,如下所示: | 57 | 首先添加必要的权限,如下所示: |
58 | 58 | ||
59 | <uses-permission android:name="android.permission.INTERNET" /> | 59 | <uses-permission android:name="android.permission.INTERNET" /> |
60 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 60 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
61 | <uses-permission android:name="android.permission.BLUETOOTH" /> | 61 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
62 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 62 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
63 | <uses-permission android:name="android.permission.WRITE_SETTINGS"/> | 63 | <uses-permission android:name="android.permission.WRITE_SETTINGS"/> |
64 | <uses-permission android:name="android.permission.GET_ACCOUNTS"/> | 64 | <uses-permission android:name="android.permission.GET_ACCOUNTS"/> |
65 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | 65 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> |
66 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | 66 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> |
67 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> | 67 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> |
68 | <!-- upay --> | 68 | |
69 | <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
70 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | ||
71 | <uses-permission android:name="android.permission.VIBRATE" /> | ||
72 | <uses-permission android:name="android.permission.SEND_SMS" /> | ||
73 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> | ||
74 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | ||
75 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
76 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
77 | <!-- for card.io card scanning --> | ||
78 | <uses-permission android:name="android.permission.CAMERA" /> | ||
79 | <uses-permission android:name="android.permission.VIBRATE" /> | ||
80 | <uses-permission android:name="android.permission.SEND_SMS" /> | ||
81 | <!--coda--> | ||
82 | <uses-permission android:name="android.permission.RECEIVE_SMS" /> | ||
83 | <uses-permission android:name="android.permission.READ_SMS" /> | ||
84 | <uses-permission android:name="android.permission.WRITE_SMS" /> | ||
85 | <uses-permission android:name="android.permission.GET_TASKS" /> | ||
86 | <uses-feature android:name="android.hardware.camera" android:required="false" /> | ||
87 | <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> | ||
88 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 69 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
89 | <uses-permission android:name="com.android.vending.BILLING" /> | 70 | <uses-permission android:name="com.android.vending.BILLING" /> |
90 | 71 | ||
91 | 其次注册相应的Activity,具体如下: | 72 | 其次注册相应的Activity,具体如下: |
92 | 73 | ||
93 | <activity | 74 | <activity |
94 | android:name="com.gumptech.sdk.ContainerActivity" | 75 | android:name="com.gumptech.sdk.ContainerActivity" |
95 | android:theme="@style/container_dialog" | 76 | android:theme="@style/container_dialog" |
96 | android:configChanges="orientation|screenLayout" > | 77 | android:configChanges="orientation|screenLayout" > |
97 | </activity> | 78 | </activity> |
98 | <activity | 79 | <activity |
99 | android:name="com.facebook.LoginActivity" | 80 | android:name="com.facebook.LoginActivity" |
100 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > | 81 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > |
101 | </activity> | 82 | </activity> |
102 | <activity | 83 | <activity |
103 | android:name="com.gumptech.sdk.PaymentActivity" | 84 | android:name="com.gumptech.sdk.PaymentActivity" |
104 | android:configChanges="orientation|screenLayout" | 85 | android:configChanges="orientation|screenLayout" |
105 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > | 86 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > |
106 | </activity> | 87 | </activity> |
107 | <activity | 88 | <activity |
108 | android:name="com.gumptech.sdk.ExchangeWindow" | 89 | android:name="com.gumptech.sdk.ExchangeWindow" |
109 | android:configChanges="orientation|screenLayout" | 90 | android:configChanges="orientation|screenLayout" |
110 | android:theme="@style/ex_win" > | 91 | android:theme="@style/ex_win" > |
111 | </activity> | 92 | </activity> |
112 | <service android:name="com.gumptech.sdk.PushService" > | 93 | <service android:name="com.gumptech.sdk.PushService" > |
113 | </service> | 94 | </service> |
114 | <!-- paypal --> | 95 | |
115 | <service | ||
116 | android:name="com.paypal.android.sdk.payments.PayPalService" | ||
117 | android:exported="false" /> | ||
118 | |||
119 | <activity android:name="com.paypal.android.sdk.payments.PaymentActivity" /> | ||
120 | <activity android:name="com.paypal.android.sdk.payments.LoginActivity" /> | ||
121 | <activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" /> | ||
122 | <activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" /> | ||
123 | <activity android:name="com.paypal.android.sdk.payments.PayPalFuturePaymentActivity" /> | ||
124 | <activity android:name="com.paypal.android.sdk.payments.FuturePaymentConsentActivity" /> | ||
125 | <activity android:name="com.paypal.android.sdk.payments.FuturePaymentInfoActivity" /> | ||
126 | <activity | ||
127 | android:name="io.card.payment.CardIOActivity" | ||
128 | android:configChanges="keyboardHidden|orientation" /> | ||
129 | <activity android:name="io.card.payment.DataEntryActivity" /> | ||
130 | <activity | ||
131 | android:name="com.android.easy2pay.Easy2PayScreen" | ||
132 | android:theme="@android:style/Theme.Translucent.NoTitleBar" /> | ||
133 | <activity | ||
134 | android:name="com.codapayments.sdk.pay.CodaWeb" | ||
135 | android:alwaysRetainTaskState="true" | ||
136 | android:configChanges="orientation|screenSize" | ||
137 | android:screenOrientation="unspecified" > | ||
138 | </activity> | ||
139 | |||
140 | <receiver | ||
141 | android:name="com.codapayments.sdk.message.PendingTxnReceiver" | ||
142 | android:enabled="true" > | ||
143 | </receiver> | ||
144 | <!-- upay --> | ||
145 | <activity | ||
146 | android:name="com.upay.billing.UpayActivity" | ||
147 | android:configChanges="orientation|keyboardHidden|screenSize" | ||
148 | android:theme="@android:style/Theme.Translucent" /> | ||
149 | <activity | ||
150 | android:name="com.upay.billing.engine.ais.AisActivity" | ||
151 | android:configChanges="orientation|keyboardHidden|screenSize" | ||
152 | android:theme="@android:style/Theme.Translucent" /> | ||
153 | |||
154 | <service android:name="com.upay.billing.sdk.LocalService" > | ||
155 | <intent-filter> | ||
156 | <action android:name="yourPackageName.LocalService" /> | ||
157 | </intent-filter> | ||
158 | </service> | ||
159 | 96 | ||
160 | #### 2、 向Gump平台索要游戏ID(GID),完成代码接入 | 97 | #### 2、 向Gump平台索要游戏ID(GID),完成代码接入 |
161 | 1.调用GumpSDK前需要执行初始化。 | 98 | 1.调用GumpSDK前需要执行初始化。 |
162 | 若不需要分渠道 | 99 | 若不需要分渠道 |
163 | 100 | ||
164 | GumpSDK.init(Context,Appid, Appkey); | 101 | GumpSDK.init(Context,Appid, Appkey); |
165 | 如果需要定义渠道,必须使用如下方法 | 102 | 如果需要定义渠道,必须使用如下方法 |
166 | 103 | ||
167 | GumpSDK.init(Context,Appid, Appkey,ChannelId); | 104 | GumpSDK.init(Context,Appid, Appkey,ChannelId); |
168 | *gump logo的显示控制方法,此方法参数指定是否显示GumpLogo | 105 | *gump logo的显示控制方法,此方法参数指定是否显示GumpLogo |
169 | 106 | ||
170 | GumpSDK.setShowLogo(boolean); | 107 | GumpSDK.setShowLogo(boolean); |
171 | 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | 108 | 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 |
172 | 109 | ||
173 | GumpSDK.start(Activity); | 110 | GumpSDK.start(Activity); |
174 | 开发者需要在调用的Activity里重写onActivityResult方法以接受用户的登录结果,通常如下: | 111 | 开发者需要在调用的Activity里重写onActivityResult方法以接受用户的登录结果,通常如下: |
175 | 112 | ||
176 | //登录请求返回结果 | 113 | //登录请求返回结果 |
177 | if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) { | 114 | if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) { |
178 | if (resultCode == RESULT_OK) { | 115 | if (resultCode == RESULT_OK) { |
179 | String uid = data.getIntExtra("userId", -1); | 116 | String uid = data.getIntExtra("userId", -1); |
180 | int accountType = data.getIntExtra("accountType", -1); | 117 | int accountType = data.getIntExtra("accountType", -1); |
181 | String sessionkey = data.getStringExtra("sessionKey"); | 118 | String sessionkey = data.getStringExtra("sessionKey"); |
182 | 119 | ||
183 | } else if (resultCode == RESULT_CANCELED) { | 120 | } else if (resultCode == RESULT_CANCELED) { |
184 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 121 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
185 | } | 122 | } |
186 | } | 123 | } |
187 | 124 | ||
188 | 如上将收到成功登录用的userid,此Id标识唯一用户! | 125 | 如上将收到成功登录用的userid,此Id标识唯一用户! |
189 | 126 | ||
190 | 3.支付功能(已过期,请优先考虑手机页面支付,参考地址:[GumpTech页面支付](http://git.letsgame.mobi/document/gumptech-document/blob/master/doc/webpay.md) ) | 127 | 3.支付功能(已过期,请优先考虑手机页面支付,参考地址:[GumpTech页面支付](http://git.letsgame.mobi/document/gumptech-document/blob/master/doc/webpay.md) ) |
191 | 1)使用gump通行证登录 | 128 | 1)使用gump通行证登录 |
192 | 129 | ||
193 | Bundle payInfo = new Bundle(); | 130 | Bundle payInfo = new Bundle(); |
194 | payInfo.putString("nick", "thi"); | 131 | payInfo.putString("nick", "thi"); |
195 | payInfo.putString("product", "元宝"); | 132 | payInfo.putString("product", "元宝"); |
196 | payInfo.putFloat("amount", 40.0f); | 133 | payInfo.putFloat("amount", 40.0f); |
197 | payInfo.putString("extraInfo", "This is demo!"); | 134 | payInfo.putString("extraInfo", "This is demo!"); |
198 | payInfo.putString("serverId", "B4003"); | 135 | payInfo.putString("serverId", "B4003"); |
199 | payInfo.putString("roleId", "10010"); | 136 | payInfo.putString("roleId", "10010"); |
200 | GumpSDK.pay(MainActivity.this, payInfo); | 137 | GumpSDK.pay(MainActivity.this, payInfo); |
201 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,可以设置值为空,但是字段必须全部包含,支付完成仍然通过onActivityResult回调,requestCode为GumpSDK.PAY_REQUEST_CODE,回调信息除code和msg外,还含有orderId和传入的extraInfo. | 138 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,可以设置值为空,但是字段必须全部包含,支付完成仍然通过onActivityResult回调,requestCode为GumpSDK.PAY_REQUEST_CODE,回调信息除code和msg外,还含有orderId和传入的extraInfo. |
202 | 2)未使用gump通行证登录,需要传入用户id | 139 | 2)未使用gump通行证登录,需要传入用户id |
203 | 140 | ||
204 | Bundle payInfo = new Bundle(); | 141 | Bundle payInfo = new Bundle(); |
205 | payInfo.putString("nick", "thi"); | 142 | payInfo.putString("nick", "thi"); |
206 | payInfo.putString("product", "元宝"); | 143 | payInfo.putString("product", "元宝"); |
207 | payInfo.putFloat("amount", 40.0f); | 144 | payInfo.putFloat("amount", 40.0f); |
208 | payInfo.putString("extraInfo", "This is demo!"); | 145 | payInfo.putString("extraInfo", "This is demo!"); |
209 | payInfo.putString("serverId", "B4003"); | 146 | payInfo.putString("serverId", "B4003"); |
210 | payInfo.putString("roleId", "10010"); | 147 | payInfo.putString("roleId", "10010"); |
211 | GumpSDK.pay(MainActivity.this, payInfo,"1021"); | 148 | GumpSDK.pay(MainActivity.this, payInfo,"1021"); |
212 | 5.注销登录 | 149 | 5.注销登录 |
213 | 150 | ||
214 | GumpSDK.logout(Activity,GumpSDK.Callback); | 151 | GumpSDK.logout(Activity,GumpSDK.Callback); |
215 | 当此方法调用后,用户退出登录,并会通过callback接口通知调用程序! | 152 | 当此方法调用后,用户退出登录,并会通过callback接口通知调用程序! |
216 | ## 第二章 常见问题 | 153 | ## 第二章 常见问题 |
217 | ### 问题1: 如何避免混淆对SDK的影响? | 154 | ### 问题1: 如何避免混淆对SDK的影响? |
218 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java | 155 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java |
219 | 类,导致SDK无法正常工作,解决方法如下: | 156 | 类,导致SDK无法正常工作,解决方法如下: |
220 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 | 157 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 |
221 | 158 | ||
222 | -keep class com.gumptech.sdk.view.* {*;} | 159 | -keep class com.gumptech.sdk.view.* {*;} |
223 | -keep class com.gumptech.sdk.web.* {*;} | 160 | -keep class com.gumptech.sdk.web.* {*;} |
224 | -keep class com.gumptech.sdk.GumpSDK$Callback{ | 161 | -keep class com.gumptech.sdk.GumpSDK$Callback{ |
225 | void onLogout(); | 162 | void onLogout(); |
226 | } | 163 | } |
227 | -keep class com.gumptech.sdk.GumpPreference{ | 164 | -keep class com.gumptech.sdk.GumpPreference{ |
228 | public static final <fields>; | 165 | public static final <fields>; |
229 | } | 166 | } |
230 | -keep class com.upay.billing.** { *; } | ||
231 | -dontwarn com.upay.billing.** | ||
232 | 167 | ||
233 | -keepattributes Signature | ||
234 | -keep class com.upay.billing.** { *; } | ||
235 | -dontwarn com.upay.billing.** | ||
236 | 使得混淆的时候不会影响SDK的命名空间。 | 168 | 使得混淆的时候不会影响SDK的命名空间。 |
237 | ### 问题2:后台已经配置ok的情况下,支付列表仍然为空或登录总是出错? | 169 | ### 问题2:后台已经配置ok的情况下,支付列表仍然为空或登录总是出错? |
238 | 解答:sdk在debug模式下使用的默认服务器地址是开发环境地址,此地址区别于正式环境地址,为开发调试用;若进行线上调试或正式环境测试,需要使用release模式来进行! | 170 | 解答:sdk在debug模式下使用的默认服务器地址是开发环境地址,此地址区别于正式环境地址,为开发调试用;若进行线上调试或正式环境测试,需要使用release模式来进行! |
239 | 一般在IDE中直接run应用到设备上使用的是debug证书安装,此时即处于debug模式;若要使用正式环境,应该使用正式证书签名打包后进行安装! | 171 | 一般在IDE中直接run应用到设备上使用的是debug证书安装,此时即处于debug模式;若要使用正式环境,应该使用正式证书签名打包后进行安装! |