Commit 04a9e9502c933dbe1899bb82264b66478d2499e5
1 parent
b71aaad8d2
Exists in
master
完成格式编辑
Showing 1 changed file with 132 additions and 185 deletions Side-by-side Diff
AndroidDocument.md
1 | - | |
2 | - | |
3 | - | |
4 | - | |
5 | - | |
6 | - | |
7 | 1 | # Gump Android SDK使用文档 |
8 | 2 | |
9 | 3 | |
... | ... | @@ -29,33 +23,13 @@ V 1.5 |
29 | 23 | |
30 | 24 | ## 目录 |
31 | 25 | |
32 | -第一章 接入指南 3 | |
33 | -配置环境 3 | |
34 | -1. 导入资源工程 3 | |
35 | -2. 添加资源工程 4 | |
36 | -3. 代码实现 5 | |
37 | -第二章 常见问题 6 | |
38 | -问题1: 如何避免混淆对SDK的影响? 6 | |
39 | - | |
40 | - | |
41 | - | |
42 | - | |
43 | - | |
44 | - | |
45 | - | |
46 | - | |
47 | - | |
48 | - | |
49 | - | |
50 | - | |
51 | - | |
52 | - | |
53 | - | |
54 | - | |
55 | - | |
56 | - | |
57 | - | |
58 | - | |
26 | +第一章 接入指南 | |
27 | +配置环境 | |
28 | +1. 导入资源工程 | |
29 | +2. 添加资源工程 | |
30 | +3. 代码实现 | |
31 | +第二章 常见问题 | |
32 | +问题1: 如何避免混淆对SDK的影响? | |
59 | 33 | |
60 | 34 | |
61 | 35 | |
... | ... | @@ -64,51 +38,21 @@ V 1.5 |
64 | 38 | 配置环境 |
65 | 39 | |
66 | 40 | 本接口API 适用于Android2.2以上各版本Android平台。 |
67 | -1. 导入资源工程 | |
41 | +### 1. 导入资源工程 | |
68 | 42 | 1.将LoginSDK资源工程拷贝到工作空间,在eclipse中的导航栏右键弹出如图1画面,选择Import导入资源工程,如图1. |
69 | 43 | |
70 | --[](images/1.png) | |
71 | - 图1 | |
72 | - | |
73 | - | |
74 | - | |
75 | - | |
76 | - | |
44 | + | |
45 | + 图1 | |
77 | 46 | |
78 | 47 | 2.导入工程后,右键此工程,在Properties->Android中选中此工程为library工程(勾选红色方框标识处)如图2。 |
79 | - | |
80 | - | |
81 | - | |
82 | - | |
83 | - | |
84 | - | |
85 | - | |
86 | - | |
87 | - | |
88 | - | |
89 | - | |
90 | - | |
91 | - | |
92 | - | |
93 | - | |
94 | - | |
95 | - 图 2 | |
96 | -2. 添加资源工程 | |
48 | + | |
49 | + 图 2 | |
50 | +### 2. 添加资源工程 | |
97 | 51 | 添加资源工程为游戏项目的 library。右键游戏项目,在Properties->Android中点击Add添加资源工程为项目工程的library,结果如图3。 |
98 | - | |
99 | - | |
100 | - | |
101 | - | |
102 | - | |
103 | - | |
104 | - | |
105 | - | |
106 | - | |
107 | - | |
108 | - | |
109 | - | |
52 | + | |
110 | 53 | 图 3 |
111 | 54 | |
55 | + | |
112 | 56 | 注意:如果ADT版本低于14,ADT不支持jar包自动引入,请手动拷贝libs到您的工作 |
113 | 57 | 空间。 |
114 | 58 | |
... | ... | @@ -116,134 +60,137 @@ Eclipse查看ADT版本号的方法: |
116 | 60 | Help==>About Eclips点击Android对应的图标就可以查看版本了. |
117 | 61 | 如图,红色框部分就是ADT版本号。 |
118 | 62 | |
63 | + | |
119 | 64 | |
120 | 65 | |
121 | - | |
122 | - | |
123 | - | |
124 | - | |
125 | - | |
126 | - | |
127 | - | |
128 | - | |
129 | - | |
130 | -3. 代码实现 | |
131 | -1、 修改AndroidManifest.xml文件 | |
66 | +### 3. 代码实现 | |
67 | +#### 1、 修改AndroidManifest.xml文件 | |
132 | 68 | 首先添加必要的权限,如下所示: |
133 | - <uses-permission android:name="android.permission.INTERNET" /> | |
69 | + | |
70 | + <uses-permission android:name="android.permission.INTERNET" /> | |
134 | 71 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
135 | 72 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
136 | -<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |
137 | -<uses-permission android:name="android.permission.WRITE_SETTINGS"/> | |
138 | -<uses-permission android:name="android.permission.GET_ACCOUNTS"/> | |
139 | -<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | |
140 | -<!-- for card.io card scanning --> | |
73 | + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |
74 | + <uses-permission android:name="android.permission.WRITE_SETTINGS"/> | |
75 | + <uses-permission android:name="android.permission.GET_ACCOUNTS"/> | |
76 | + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | |
77 | + <!-- for card.io card scanning --> | |
141 | 78 | <uses-permission android:name="android.permission.CAMERA" /> |
142 | 79 | <uses-permission android:name="android.permission.VIBRATE" /> |
143 | 80 | <uses-feature android:name="android.hardware.camera" android:required="false" /> |
144 | 81 | <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> |
145 | 82 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
146 | 83 | <uses-permission android:name="com.android.vending.BILLING" /> |
84 | + | |
147 | 85 | 其次注册相应的Activity,具体如下: |
148 | - <activity | |
149 | - android:name="com.gumptech.sdk.ContainerActivity" | |
150 | - android:theme="@style/container_dialog" | |
151 | - android:configChanges="orientation|screenLayout" > | |
152 | - </activity> | |
153 | - <activity | |
154 | - android:name="com.facebook.LoginActivity" | |
155 | - android:theme="@android:style/Theme.Translucent.NoTitleBar" > | |
156 | - </activity> | |
86 | + | |
87 | + <activity | |
88 | + android:name="com.gumptech.sdk.ContainerActivity" | |
89 | + android:theme="@style/container_dialog" | |
90 | + android:configChanges="orientation|screenLayout" > | |
91 | + </activity> | |
92 | + <activity | |
93 | + android:name="com.facebook.LoginActivity" | |
94 | + android:theme="@android:style/Theme.Translucent.NoTitleBar" > | |
95 | + </activity> | |
157 | 96 | <activity |
158 | - android:name="com.gumptech.sdk.PaymentActivity" | |
159 | - android:configChanges="orientation|screenLayout" | |
160 | - android:theme="@android:style/Theme.Translucent.NoTitleBar" > | |
161 | - </activity> | |
162 | - <!-- paypal --> | |
163 | - <service | |
164 | - android:name="com.paypal.android.sdk.payments.PayPalService" | |
165 | - android:exported="false" /> | |
166 | - | |
167 | - <activity android:name="com.paypal.android.sdk.payments.PaymentActivity" /> | |
168 | - <activity android:name="com.paypal.android.sdk.payments.LoginActivity" /> | |
169 | - <activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" /> | |
170 | - <activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" /> | |
171 | - <activity android:name="com.paypal.android.sdk.payments.PayPalFuturePaymentActivity" /> | |
172 | - <activity android:name="com.paypal.android.sdk.payments.FuturePaymentConsentActivity" /> | |
173 | - <activity android:name="com.paypal.android.sdk.payments.FuturePaymentInfoActivity" /> | |
174 | - <activity | |
175 | - android:name="io.card.payment.CardIOActivity" | |
176 | - android:configChanges="keyboardHidden|orientation" /> | |
177 | - <activity android:name="io.card.payment.DataEntryActivity" /> | |
178 | -2、 向Gump平台索要游戏ID(GID),完成代码接入 | |
179 | - 1.调用GumpSDK前需要执行初始化。 | |
180 | - 若需要不需要分渠道 | |
181 | - GumpSDK.init(Appid, Appkey,FacebookId); | |
182 | - 如果需要定义渠道,必须使用如下方法 | |
183 | - GumpSDK.init(Appid, Appkey,FacebookId,ChannelId); | |
184 | - 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | |
185 | - GumpSDK.start(Activity); | |
186 | - 开发者需要在调用的Activity里重写onActivityResult方法以接受用户的登录结果,通常如下: | |
187 | - //登录请求返回结果 | |
188 | - if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) { | |
189 | - if (resultCode == RESULT_OK) { | |
190 | - int uid = data.getIntExtra("userId", -1); | |
191 | - int accountType = data.getIntExtra("accountType", -1); | |
192 | - String sessionkey = data.getStringExtra("sessionKey"); | |
97 | + android:name="com.gumptech.sdk.PaymentActivity" | |
98 | + android:configChanges="orientation|screenLayout" | |
99 | + android:theme="@android:style/Theme.Translucent.NoTitleBar" > | |
100 | + </activity> | |
101 | + <!-- paypal --> | |
102 | + <service | |
103 | + android:name="com.paypal.android.sdk.payments.PayPalService" | |
104 | + android:exported="false" /> | |
105 | + | |
106 | + <activity android:name="com.paypal.android.sdk.payments.PaymentActivity" /> | |
107 | + <activity android:name="com.paypal.android.sdk.payments.LoginActivity" /> | |
108 | + <activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" /> | |
109 | + <activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" /> | |
110 | + <activity android:name="com.paypal.android.sdk.payments.PayPalFuturePaymentActivity" /> | |
111 | + <activity android:name="com.paypal.android.sdk.payments.FuturePaymentConsentActivity" /> | |
112 | + <activity android:name="com.paypal.android.sdk.payments.FuturePaymentInfoActivity" /> | |
113 | + <activity | |
114 | + android:name="io.card.payment.CardIOActivity" | |
115 | + android:configChanges="keyboardHidden|orientation" /> | |
116 | + <activity android:name="io.card.payment.DataEntryActivity" /> | |
117 | + | |
118 | +#### 2、 向Gump平台索要游戏ID(GID),完成代码接入 | |
119 | +1.调用GumpSDK前需要执行初始化。 | |
120 | +若不需要分渠道 | |
121 | + | |
122 | + GumpSDK.init(Appid, Appkey,FacebookId); | |
123 | +如果需要定义渠道,必须使用如下方法 | |
124 | + | |
125 | + GumpSDK.init(Appid, Appkey,FacebookId,ChannelId); | |
126 | +2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | |
127 | + | |
128 | + GumpSDK.start(Activity); | |
129 | +开发者需要在调用的Activity里重写onActivityResult方法以接受用户的登录结果,通常如下: | |
130 | + | |
131 | + //登录请求返回结果 | |
132 | + if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) { | |
133 | + if (resultCode == RESULT_OK) { | |
134 | + int uid = data.getIntExtra("userId", -1); | |
135 | + int accountType = data.getIntExtra("accountType", -1); | |
136 | + String sessionkey = data.getStringExtra("sessionKey"); | |
193 | 137 | |
194 | - } else if (resultCode == RESULT_CANCELED) { | |
195 | - Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | |
196 | - } | |
138 | + } else if (resultCode == RESULT_CANCELED) { | |
139 | + Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | |
197 | 140 | } |
198 | -如上将收到成功登录用的userid,此Id标识唯一用户! | |
141 | + } | |
142 | + | |
143 | +如上将收到成功登录用的userid,此Id标识唯一用户! | |
199 | 144 | 3.用户绑定邮箱,并填写密码 |
200 | - GumpSDK.boundMail(MainActivity.this); | |
201 | -开发者需要在调用的Activity里重写onActivityResult方法以接受用户的绑定结果,通常如下: | |
202 | -//绑定邮箱请求返回结果 | |
203 | - if (requestCode == GumpSDK.BOUND_REQUEST_CODE) { | |
204 | - if (resultCode == RESULT_OK) { | |
205 | - int uid = data.getIntExtra("userId", -1); | |
206 | - int accountType = data.getIntExtra("accountType", -1); | |
207 | - String sessionkey = data.getStringExtra("sessionKey"); | |
208 | - } else if (resultCode == RESULT_CANCELED) { | |
209 | - Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | |
210 | - } | |
211 | -} | |
212 | -4.支付功能 | |
213 | - Bundle payInfo = new Bundle(); | |
214 | - payInfo.putString("nick", "thi"); | |
215 | - payInfo.putString("product", "元宝"); | |
216 | - payInfo.putFloat("amount", 40.0f); | |
217 | - payInfo.putString("extraInfo", "This is demo!"); | |
218 | - GumpSDK.pay(MainActivity.this, payInfo); | |
219 | - 调用pay方法时,必须穿入一个bundle对象,包含如上字段,可以设置值为空,但是字段必须全部包含,支付完成仍然通过onActivityResult回调,requestCode为GumpSDK.PAY_REQUEST_CODE,回调信息除code和msg外,还含有orderId和传入的extraInfo. | |
220 | - 5.注销登录 | |
221 | - GumpSDK.logout(Activity,GumpSDK.Callback); | |
222 | - 当此方法调用后,用户退出登录,并会通过callback接口通知调用程序! | |
223 | -第二章 常见问题 | |
224 | ---- | |
225 | -问题1: 如何避免混淆对SDK的影响? | |
226 | -解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java | |
227 | -类,导致SDK无法正常工作,解决方法如下: | |
228 | -Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加 | |
229 | -上 | |
230 | --keep class com.gumptech.sdk.GumpSDK{ | |
231 | -public static final <fields>; | |
232 | -public static void init(java.lang.String,java.lang.String); | |
233 | -public static void init(java.lang.String,java.lang.String,java.lang.String,java.lang.String); | |
234 | -public static void start(android.app.Activity); | |
235 | -public static void logout(android.app.Activity); | |
236 | -public static void boundMail(android.app.Activity); | |
237 | -} | |
238 | --keep class com.gumptech.sdk.view.* {*;} | |
239 | --keep class com.gumptech.sdk.GumpSDK$Callback{ | |
240 | - void onLogout(); | |
241 | -} | |
242 | --keep class com.gumptech.sdk.GumpPreference{ | |
243 | -public static final <fields>; | |
244 | -} | |
245 | --keep class com.facebook.** { *; } | |
246 | - | |
247 | --keepattributes Signature | |
248 | -使得混淆的时候不会影响SDK的命名空间。 | |
249 | 145 | |
146 | + GumpSDK.boundMail(MainActivity.this); | |
147 | +开发者需要在调用的Activity里重写onActivityResult方法以接受用户的绑定结果,通常如下: | |
148 | + | |
149 | + //绑定邮箱请求返回结果 | |
150 | + if (requestCode == GumpSDK.BOUND_REQUEST_CODE) { | |
151 | + if (resultCode == RESULT_OK) { | |
152 | + int uid = data.getIntExtra("userId", -1); | |
153 | + int accountType = data.getIntExtra("accountType", -1); | |
154 | + String sessionkey = data.getStringExtra("sessionKey"); | |
155 | + } else if (resultCode == RESULT_CANCELED) { | |
156 | + Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | |
157 | + } | |
158 | + } | |
159 | +4.支付功能 | |
160 | + | |
161 | + Bundle payInfo = new Bundle(); | |
162 | + payInfo.putString("nick", "thi"); | |
163 | + payInfo.putString("product", "元宝"); | |
164 | + payInfo.putFloat("amount", 40.0f); | |
165 | + payInfo.putString("extraInfo", "This is demo!"); | |
166 | + GumpSDK.pay(MainActivity.this, payInfo); | |
167 | +调用pay方法时,必须穿入一个bundle对象,包含如上字段,可以设置值为空,但是字段必须全部包含,支付完成仍然通过onActivityResult回调,requestCode为GumpSDK.PAY_REQUEST_CODE,回调信息除code和msg外,还含有orderId和传入的extraInfo. | |
168 | +5.注销登录 | |
169 | + | |
170 | + GumpSDK.logout(Activity,GumpSDK.Callback); | |
171 | +当此方法调用后,用户退出登录,并会通过callback接口通知调用程序! | |
172 | +## 第二章 常见问题 | |
173 | +问题1: 如何避免混淆对SDK的影响? | |
174 | +解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java | |
175 | +类,导致SDK无法正常工作,解决方法如下: | |
176 | +Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 | |
177 | + | |
178 | + -keep class com.gumptech.sdk.GumpSDK{ | |
179 | + public static final <fields>; | |
180 | + public static void init(java.lang.String,java.lang.String); | |
181 | + public static void init(java.lang.String,java.lang.String,java.lang.String,java.lang.String); | |
182 | + public static void start(android.app.Activity); | |
183 | + public static void logout(android.app.Activity); | |
184 | + public static void boundMail(android.app.Activity); | |
185 | + } | |
186 | + -keep class com.gumptech.sdk.view.* {*;} | |
187 | + -keep class com.gumptech.sdk.GumpSDK$Callback{ | |
188 | + void onLogout(); | |
189 | + } | |
190 | + -keep class com.gumptech.sdk.GumpPreference{ | |
191 | + public static final <fields>; | |
192 | + } | |
193 | + -keep class com.facebook.** { *; } | |
194 | + | |
195 | + -keepattributes Signature | |
196 | +使得混淆的时候不会影响SDK的命名空间。 | |
250 | 197 | \ No newline at end of file |