Commit 05bcef797c5ba4930cd61b56df50e288ad7128ca
1 parent
305f038e7b
Exists in
master
增加Google登录
Showing 7 changed files with 10 additions and 7 deletions Inline Diff
GameSDK-ND-release4.2.0.aar
No preview for this file type
GameSDK-release4.1.7.aar
No preview for this file type
GameSDKDemo/build.gradle
| 1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
| 2 | 2 | ||
| 3 | repositories{ | 3 | repositories{ |
| 4 | flatDir{ | 4 | flatDir{ |
| 5 | dirs 'libs' | 5 | dirs 'libs' |
| 6 | } | 6 | } |
| 7 | } | 7 | } |
| 8 | 8 | ||
| 9 | android { | 9 | android { |
| 10 | compileSdkVersion 22 | 10 | compileSdkVersion 22 |
| 11 | buildToolsVersion "25.0.0" | 11 | buildToolsVersion "25.0.0" |
| 12 | 12 | ||
| 13 | defaultConfig { | 13 | defaultConfig { |
| 14 | minSdkVersion 9 | 14 | minSdkVersion 9 |
| 15 | targetSdkVersion 22 | 15 | targetSdkVersion 22 |
| 16 | versionCode 1000002 | 16 | versionCode 1000002 |
| 17 | versionName "1.0.2" | 17 | versionName "1.0.2" |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | buildTypes { | 20 | buildTypes { |
| 21 | release { | 21 | release { |
| 22 | minifyEnabled false | 22 | minifyEnabled false |
| 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 24 | } | 24 | } |
| 25 | } | 25 | } |
| 26 | lintOptions{ | 26 | lintOptions{ |
| 27 | abortOnError false | 27 | abortOnError false |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | dependencies { | 31 | dependencies { |
| 32 | compile fileTree(dir: 'libs', include: ['*.jar']) | 32 | compile fileTree(dir: 'libs', include: ['*.jar']) |
| 33 | testCompile 'junit:junit:4.12' | 33 | testCompile 'junit:junit:4.12' |
| 34 | compile 'com.android.support:appcompat-v7:22.2.0' | 34 | compile 'com.android.support:appcompat-v7:22.2.0' |
| 35 | // compile project(':GameSDK') | 35 | // compile project(':GameSDK') |
| 36 | compile(name:'GameSDK-release4.1.6',ext:'aar') | 36 | compile(name:'GameSDK-ND-release4.2.0',ext:'aar') |
| 37 | } | 37 | } |
| 38 | 38 |
GameSDKDemo/libs/GameSDK-ND-release4.2.0.aar
No preview for this file type
GameSDKDemo/libs/GameSDK-release4.1.7.aar
No preview for this file type
GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
| 1 | package com.gumptech.sdk.demo; | 1 | package com.gumptech.sdk.demo; |
| 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.g.root.GumpPreference; | 13 | import com.g.root.GumpPreference; |
| 14 | import com.g.root.GumpSDK; | 14 | import com.g.root.GumpSDK; |
| 15 | import com.g.root.PaymentVersion; | 15 | import com.g.root.PaymentVersion; |
| 16 | import com.g.root.bean.GumpUser; | 16 | import com.g.root.bean.GumpUser; |
| 17 | import com.g.root.bean.PurchaseResult; | 17 | import com.g.root.bean.PurchaseResult; |
| 18 | import com.g.root.callback.InitializeCallback; | 18 | import com.g.root.callback.InitializeCallback; |
| 19 | import com.g.root.callback.LoginStateListener; | 19 | import com.g.root.callback.LoginStateListener; |
| 20 | import com.g.root.callback.PurchaseCallback; | 20 | import com.g.root.callback.PurchaseCallback; |
| 21 | import com.g.root.passport.fb.FBAccessToken; | 21 | import com.g.root.passport.fb.FBAccessToken; |
| 22 | 22 | ||
| 23 | public class MainActivity extends Activity implements PurchaseCallback { | 23 | public class MainActivity extends Activity implements PurchaseCallback { |
| 24 | 24 | ||
| 25 | private static final String TAG = "MainActivity"; | 25 | private static final String TAG = "MainActivity"; |
| 26 | 26 | ||
| 27 | private TextView tvVersion; | 27 | private TextView tvVersion; |
| 28 | private TextView userInfo; | 28 | private TextView userInfo; |
| 29 | 29 | ||
| 30 | private Button btnLoginOrLogout; | 30 | private Button btnLoginOrLogout; |
| 31 | 31 | ||
| 32 | private String appId = "10022"; | 32 | private String appId = "10022"; |
| 33 | private String appKey = "7e0ff37942c2de60cbcbd27041196ce3"; | 33 | private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; |
| 34 | private String sessionKey; | 34 | private String sessionKey; |
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | @Override | 37 | @Override |
| 38 | protected void onCreate(Bundle savedInstanceState) { | 38 | protected void onCreate(Bundle savedInstanceState) { |
| 39 | super.onCreate(savedInstanceState); | 39 | super.onCreate(savedInstanceState); |
| 40 | setContentView(R.layout.activity_main); | 40 | setContentView(R.layout.activity_main); |
| 41 | tvVersion = (TextView) findViewById(R.id.version); | 41 | tvVersion = (TextView) findViewById(R.id.version); |
| 42 | userInfo = (TextView) findViewById(R.id.user_info); | 42 | userInfo = (TextView) findViewById(R.id.user_info); |
| 43 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); | 43 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); |
| 44 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | 44 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { |
| 45 | 45 | ||
| 46 | @Override | 46 | @Override |
| 47 | public void onClick(View v) { | 47 | public void onClick(View v) { |
| 48 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | 48 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) |
| 49 | GumpSDK.start(MainActivity.this); | 49 | GumpSDK.start(MainActivity.this); |
| 50 | else | 50 | else |
| 51 | GumpSDK.logout(MainActivity.this); | 51 | GumpSDK.logout(MainActivity.this); |
| 52 | } | 52 | } |
| 53 | }); | 53 | }); |
| 54 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | 54 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { |
| 55 | 55 | ||
| 56 | @Override | 56 | @Override |
| 57 | public void onClick(View v) { | 57 | public void onClick(View v) { |
| 58 | Bundle payInfo = new Bundle(); | 58 | Bundle payInfo = new Bundle(); |
| 59 | payInfo.putString("product", "test2"); | 59 | payInfo.putString("product", "test2"); |
| 60 | payInfo.putFloat("amount", 0.1f); | 60 | payInfo.putFloat("amount", 0.1f); |
| 61 | payInfo.putString("extraInfo", "This is demo!"); | 61 | payInfo.putString("extraInfo", "This is demo!"); |
| 62 | payInfo.putString("serverId", "100"); | 62 | payInfo.putString("serverId", "100"); |
| 63 | payInfo.putString("roleId","100123"); | 63 | payInfo.putString("roleId","100123"); |
| 64 | payInfo.putString("sessionKey", sessionKey); | 64 | payInfo.putString("sessionKey", sessionKey); |
| 65 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); | 65 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); |
| 66 | } | 66 | } |
| 67 | }); | 67 | }); |
| 68 | findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { | 68 | findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { |
| 69 | @Override | 69 | @Override |
| 70 | public void onClick(View v) { | 70 | public void onClick(View v) { |
| 71 | Bundle payInfo = new Bundle(); | 71 | Bundle payInfo = new Bundle(); |
| 72 | payInfo.putString("product", "renmbl.9"); | 72 | payInfo.putString("product", "renmbl.9"); |
| 73 | payInfo.putFloat("amount", 0.1f); | 73 | payInfo.putFloat("amount", 0.1f); |
| 74 | payInfo.putString("extraInfo", "This is demo!"); | 74 | payInfo.putString("extraInfo", "This is demo!"); |
| 75 | payInfo.putString("serverId", "100"); | 75 | payInfo.putString("serverId", "100"); |
| 76 | payInfo.putString("roleId","100123"); | 76 | payInfo.putString("roleId","100123"); |
| 77 | GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); | 77 | GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); |
| 78 | } | 78 | } |
| 79 | }); | 79 | }); |
| 80 | /** | 80 | /** |
| 81 | * 设置否是打印debug日志 | 81 | * 设置否是打印debug日志 |
| 82 | */ | 82 | */ |
| 83 | GumpSDK.getSettings().enableDebugLogging(true); | 83 | GumpSDK.getSettings().enableDebugLogging(true); |
| 84 | /** | 84 | /** |
| 85 | * 设置是否启用facebook登录 | 85 | * 设置是否启用facebook登录 |
| 86 | */ | 86 | */ |
| 87 | GumpSDK.getSettings().setFBEnable(true); | 87 | GumpSDK.getSettings().setFBEnable(true); |
| 88 | /** | 88 | /** |
| 89 | * 设置是否启用Vk登录 | 89 | * 设置是否启用Vk登录 |
| 90 | */ | 90 | */ |
| 91 | GumpSDK.getSettings().setVKEnable(false); | 91 | GumpSDK.getSettings().setVKEnable(false); |
| 92 | /** | 92 | /** |
| 93 | * 设置屏幕方向 | 93 | * 设置屏幕方向 |
| 94 | */ | 94 | */ |
| 95 | GumpSDK.getSettings().setScreenLandscape(true); | 95 | GumpSDK.getSettings().setScreenLandscape(true); |
| 96 | 96 | ||
| 97 | /** | 97 | /** |
| 98 | * 设置支付版本 | 98 | * 设置支付版本 |
| 99 | */ | 99 | */ |
| 100 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | 100 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); |
| 101 | 101 | ||
| 102 | /** | 102 | /** |
| 103 | * 设置用户登录状态监听器 | 103 | * 设置用户登录状态监听器 |
| 104 | */ | 104 | */ |
| 105 | 105 | ||
| 106 | GumpSDK.setUserStateListener(new LoginStateListener() { | 106 | GumpSDK.setUserStateListener(new LoginStateListener() { |
| 107 | @Override | 107 | @Override |
| 108 | public void onLoginSuccess(GumpUser user) { | 108 | public void onLoginSuccess(GumpUser user) { |
| 109 | ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | 109 | ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); |
| 110 | cm.setText(user.getSessionKey()); | 110 | cm.setText(user.getSessionKey()); |
| 111 | sessionKey = user.getSessionKey(); | 111 | sessionKey = user.getSessionKey(); |
| 112 | String userType = null; | 112 | String userType = null; |
| 113 | switch (user.getAccountType()) { | 113 | switch (user.getAccountType()) { |
| 114 | case GumpPreference.ACCOUNT_TYPE_FB: | 114 | case GumpPreference.ACCOUNT_TYPE_FB: |
| 115 | userType = "Facebook登录"; | 115 | userType = "Facebook登录"; |
| 116 | String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); | 116 | String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); |
| 117 | Log.d(TAG, "FBAccessToken:" + fbToken); | 117 | Log.d(TAG, "FBAccessToken:" + fbToken); |
| 118 | break; | 118 | break; |
| 119 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | 119 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: |
| 120 | userType = "快速登录"; | 120 | userType = "快速登录"; |
| 121 | break; | 121 | break; |
| 122 | case GumpPreference.ACCOUNT_TYPE_REG: | 122 | case GumpPreference.ACCOUNT_TYPE_REG: |
| 123 | userType = "gump注册用户"; | 123 | userType = "gump注册用户"; |
| 124 | break; | 124 | break; |
| 125 | case GumpPreference.ACCOUNT_TYPE_VK: | 125 | case GumpPreference.ACCOUNT_TYPE_VK: |
| 126 | userType = "vk登录"; | 126 | userType = "vk登录"; |
| 127 | break; | 127 | break; |
| 128 | case GumpPreference.ACCOUNT_TYPE_GOOGLE: | ||
| 129 | userType = "Google登录"; | ||
| 130 | break; | ||
| 128 | } | 131 | } |
| 129 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey()); | 132 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey()); |
| 130 | btnLoginOrLogout.setText("Logout"); | 133 | btnLoginOrLogout.setText("Logout"); |
| 131 | btnLoginOrLogout.setTag(1); | 134 | btnLoginOrLogout.setTag(1); |
| 132 | } | 135 | } |
| 133 | 136 | ||
| 134 | @Override | 137 | @Override |
| 135 | public void onLoginFailed(int code, String msg) { | 138 | public void onLoginFailed(int code, String msg) { |
| 136 | userInfo.setText(msg); | 139 | userInfo.setText(msg); |
| 137 | Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); | 140 | Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); |
| 138 | } | 141 | } |
| 139 | 142 | ||
| 140 | @Override | 143 | @Override |
| 141 | public void onLoginCanceled() { | 144 | public void onLoginCanceled() { |
| 142 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 145 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
| 143 | } | 146 | } |
| 144 | 147 | ||
| 145 | @Override | 148 | @Override |
| 146 | public void onLogout() { | 149 | public void onLogout() { |
| 147 | btnLoginOrLogout.setText("Login"); | 150 | btnLoginOrLogout.setText("Login"); |
| 148 | btnLoginOrLogout.setTag(0); | 151 | btnLoginOrLogout.setTag(0); |
| 149 | userInfo.setText("User is logout"); | 152 | userInfo.setText("User is logout"); |
| 150 | } | 153 | } |
| 151 | }); | 154 | }); |
| 152 | /** | 155 | /** |
| 153 | * 初始化sdk | 156 | * 初始化sdk |
| 154 | */ | 157 | */ |
| 155 | GumpSDK.init(getApplicationContext(), appId, appKey, "1003", new InitializeCallback() { | 158 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { |
| 156 | @Override | 159 | @Override |
| 157 | public void initComplete(int result) { | 160 | public void initComplete(int result) { |
| 158 | if (result == GumpSDK.CODE.OK) { | 161 | if (result == GumpSDK.CODE.OK) { |
| 159 | btnLoginOrLogout.setEnabled(true); | 162 | btnLoginOrLogout.setEnabled(true); |
| 160 | } | 163 | } |
| 161 | } | 164 | } |
| 162 | }); | 165 | }); |
| 163 | 166 | ||
| 164 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | 167 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); |
| 165 | 168 | ||
| 166 | } | 169 | } |
| 167 | 170 | ||
| 168 | @Override | 171 | @Override |
| 169 | public void onPurchaseCompleted(PurchaseResult result) { | 172 | public void onPurchaseCompleted(PurchaseResult result) { |
| 170 | Log.i(TAG, "purchase completed"); | 173 | Log.i(TAG, "purchase completed"); |
| 171 | } | 174 | } |
| 172 | 175 | ||
| 173 | @Override | 176 | @Override |
| 174 | public void onPurchaseError(int code, String msg) { | 177 | public void onPurchaseError(int code, String msg) { |
| 175 | Log.i(TAG, "purchase error"); | 178 | Log.i(TAG, "purchase error"); |
| 176 | } | 179 | } |
| 177 | 180 | ||
| 178 | @Override | 181 | @Override |
| 179 | public void onPurchaseCanceled() { | 182 | public void onPurchaseCanceled() { |
| 180 | Log.i(TAG, "purchase canceled"); | 183 | Log.i(TAG, "purchase canceled"); |
| 181 | } | 184 | } |
| 182 | 185 | ||
| 183 | 186 | ||
| 184 | } | 187 | } |
| 185 | 188 |
IntegrationGuide.md
| 1 | # Gump SDK 4 for Android接入文档 | 1 | # Gump SDK 4 for Android接入文档 |
| 2 | 2 | ||
| 3 | V4.1.5 | 3 | V4.2.0 |
| 4 | 2017年3月10日 | 4 | 2017年4月26日 |
| 5 | 5 | ||
| 6 | ## 版本概述 | 6 | ## 版本概述 |
| 7 | 7 | ||
| 8 | 此版本为使用AndroidStudio开发的第一个版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. | 8 | 此版本为使用AndroidStudio开发的第一个版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. |
| 9 | 9 | ||
| 10 | 此SDK适用android2.3以上系统. | 10 | 此SDK适用android2.3以上系统. |
| 11 | 11 | ||
| 12 | ## 第一章 接入指南 | 12 | ## 第一章 接入指南 |
| 13 | ### 1.依赖导入 | 13 | ### 1.依赖导入 |
| 14 | 将aar添加到libs目录下,然后配置gradle | 14 | 将aar添加到libs目录下,然后配置gradle |
| 15 | 以下为必须项 | 15 | 以下为必须项 |
| 16 | 16 | ||
| 17 | repositories{ | 17 | repositories{ |
| 18 | flatDir{ | 18 | flatDir{ |
| 19 | dirs 'libs' | 19 | dirs 'libs' |
| 20 | } | 20 | } |
| 21 | } | 21 | } |
| 22 | dependencies { | 22 | dependencies { |
| 23 | compile(name:'GameSDK-releaseXXX',ext:'aar') | 23 | compile(name:'GameSDK-releaseXXX',ext:'aar') |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 可选接入vk登录时,需要导入vkLibrary工程,并配置模块依赖,如下 | 27 | 可选接入vk登录时,需要导入vkLibrary工程,并配置模块依赖,如下 |
| 28 | 28 | ||
| 29 | compile project(':vksdk_library') | 29 | compile project(':vksdk_library') |
| 30 | 30 | ||
| 31 | ### 2.修改AndroidManifest.xml文件 | 31 | ### 2.修改AndroidManifest.xml文件 |
| 32 | 首先添加必要的权限,如下所示: | 32 | 首先添加必要的权限,如下所示: |
| 33 | 33 | ||
| 34 | <uses-permission android:name="android.permission.INTERNET" /> | 34 | <uses-permission android:name="android.permission.INTERNET" /> |
| 35 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 35 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
| 36 | <uses-permission android:name="android.permission.BLUETOOTH" /> | 36 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
| 37 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 37 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
| 38 | <uses-permission android:name="android.permission.WRITE_SETTINGS"/> | 38 | <uses-permission android:name="android.permission.WRITE_SETTINGS"/> |
| 39 | <uses-permission android:name="android.permission.GET_ACCOUNTS"/> | 39 | <uses-permission android:name="android.permission.GET_ACCOUNTS"/> |
| 40 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | 40 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> |
| 41 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | 41 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> |
| 42 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> | 42 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> |
| 43 | <uses-permission android:name="android.permission.SEND_SMS"/> | 43 | <uses-permission android:name="android.permission.SEND_SMS"/> |
| 44 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 44 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
| 45 | <uses-permission android:name="com.android.vending.BILLING" /> | 45 | <uses-permission android:name="com.android.vending.BILLING" /> |
| 46 | 46 | ||
| 47 | 其次注册相应的Activity,具体如下: | 47 | 其次注册相应的Activity,具体如下: |
| 48 | 48 | ||
| 49 | <activity | 49 | <activity |
| 50 | android:name="com.g.root.ContainerActivity" | 50 | android:name="com.g.root.ContainerActivity" |
| 51 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 51 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 52 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan" | 52 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan" |
| 53 | android:launchMode="singleTask" | 53 | android:launchMode="singleTask" |
| 54 | android:theme="@style/Theme.TransparentWin" > | 54 | android:theme="@style/Theme.TransparentWin" > |
| 55 | </activity> | 55 | </activity> |
| 56 | <activity | 56 | <activity |
| 57 | android:name="com.g.root.PaymentActivity" | 57 | android:name="com.g.root.PaymentActivity" |
| 58 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 58 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 59 | android:launchMode="singleTask" | 59 | android:launchMode="singleTask" |
| 60 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > | 60 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > |
| 61 | <intent-filter> | 61 | <intent-filter> |
| 62 | <category android:name="android.intent.category.DEFAULT" /> | 62 | <category android:name="android.intent.category.DEFAULT" /> |
| 63 | <action android:name="android.intent.action.VIEW" /> | 63 | <action android:name="android.intent.action.VIEW" /> |
| 64 | <category android:name="android.intent.category.BROWSABLE" /> | 64 | <category android:name="android.intent.category.BROWSABLE" /> |
| 65 | <data | 65 | <data |
| 66 | android:host="com.gump.sdk" | 66 | android:host="com.gump.sdk" |
| 67 | android:scheme="gump+游戏的appId" /> | 67 | android:scheme="gump+游戏的appId" /> |
| 68 | </intent-filter> | 68 | </intent-filter> |
| 69 | </activity> | 69 | </activity> |
| 70 | <activity | 70 | <activity |
| 71 | android:name="com.g.root.ExchangeWindow" | 71 | android:name="com.g.root.ExchangeWindow" |
| 72 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 72 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 73 | android:theme="@style/Theme.WinForExchange" > | 73 | android:theme="@style/Theme.WinForExchange" > |
| 74 | </activity> | 74 | </activity> |
| 75 | 75 | ||
| 76 | <service android:name="com.g.root.PushService" /> | 76 | <service android:name="com.g.root.PushService" /> |
| 77 | 77 | ||
| 78 | <!-- vk登录使用,若不接入vk,不需配置 --> | 78 | <!-- vk登录使用,若不接入vk,不需配置 --> |
| 79 | <activity android:name="com.vk.sdk.VKOpenAuthActivity" /> | 79 | <activity android:name="com.vk.sdk.VKOpenAuthActivity" /> |
| 80 | <activity | 80 | <activity |
| 81 | android:name="com.vk.sdk.VKServiceActivity" | 81 | android:name="com.vk.sdk.VKServiceActivity" |
| 82 | android:label="ServiceActivity" | 82 | android:label="ServiceActivity" |
| 83 | android:theme="@style/VK.Transparent" /> | 83 | android:theme="@style/VK.Transparent" /> |
| 84 | 84 | ||
| 85 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 | 85 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 |
| 86 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 | 86 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 |
| 87 | 87 | ||
| 88 | *是否打印debug日志 | 88 | *是否打印debug日志 |
| 89 | 89 | ||
| 90 | GumpSDK.getSettings().enableDebugLogging(true); | 90 | GumpSDK.getSettings().enableDebugLogging(true); |
| 91 | 91 | ||
| 92 | *Gump Logo隐藏 | 92 | *Gump Logo隐藏 |
| 93 | 93 | ||
| 94 | GumpSDK.getSettings().setLogoShow(false); | 94 | GumpSDK.getSettings().setLogoShow(false); |
| 95 | 95 | ||
| 96 | *横竖屏控制,默认为横屏,参数为false即为竖屏 | 96 | *横竖屏控制,默认为横屏,参数为false即为竖屏 |
| 97 | 97 | ||
| 98 | GumpSDK.getSettings().setScreenLandscape(true); | 98 | GumpSDK.getSettings().setScreenLandscape(true); |
| 99 | 99 | ||
| 100 | *设置是否启用Facebook登录和VK登录 | 100 | *设置是否启用Facebook登录和VK登录 |
| 101 | 101 | ||
| 102 | GumpSDK.getSettings().setFBEnable(true); | 102 | GumpSDK.getSettings().setFBEnable(true); |
| 103 | GumpSDK.getSettings().setVKEnable(true); | 103 | GumpSDK.getSettings().setVKEnable(true); |
| 104 | 104 | ||
| 105 | *若要使用V4版支付请设置 | 105 | *若要使用V4版支付请设置 |
| 106 | 106 | ||
| 107 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | 107 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); |
| 108 | 108 | ||
| 109 | #### 1.调用GumpSDK前需要执行初始化。 | 109 | #### 1.调用GumpSDK前需要执行初始化。 |
| 110 | 110 | ||
| 111 | 若不需要分渠道 | 111 | 若不需要分渠道 |
| 112 | 112 | ||
| 113 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); | 113 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); |
| 114 | 如果需要定义渠道,必须使用如下方法 | 114 | 如果需要定义渠道,必须使用如下方法 |
| 115 | 115 | ||
| 116 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); | 116 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); |
| 117 | 117 | ||
| 118 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 | 118 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 |
| 119 | 119 | ||
| 120 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | 120 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 |
| 121 | 121 | ||
| 122 | GumpSDK.start(Activity); | 122 | GumpSDK.start(Activity); |
| 123 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: | 123 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: |
| 124 | 124 | ||
| 125 | GumpSDK.setUserStateListener(new LoginStateListener() { | 125 | GumpSDK.setUserStateListener(new LoginStateListener() { |
| 126 | @Override | 126 | @Override |
| 127 | public void onLoginSuccess(GumpUser gumpUser) { | 127 | public void onLoginSuccess(GumpUser gumpUser) { |
| 128 | //登录成功,用户信息包含在GumpUser对象里 | 128 | //登录成功,用户信息包含在GumpUser对象里 |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | @Override | 131 | @Override |
| 132 | public void onLoginFailed(int code, String msg) { | 132 | public void onLoginFailed(int code, String msg) { |
| 133 | //登录出错,根据错误码和信息判断错误类型 | 133 | //登录出错,根据错误码和信息判断错误类型 |
| 134 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | 134 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | @Override | 137 | @Override |
| 138 | public void onLoginCanceled() { | 138 | public void onLoginCanceled() { |
| 139 | //用户取消登录 | 139 | //用户取消登录 |
| 140 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 140 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | @Override | 143 | @Override |
| 144 | public void onLogout() { | 144 | public void onLogout() { |
| 145 | //用户登出 | 145 | //用户登出 |
| 146 | 146 | ||
| 147 | } | 147 | } |
| 148 | }); | 148 | }); |
| 149 | 149 | ||
| 150 | 如上成功登录后收到的GumpUser对象包含以下信息 | 150 | 如上成功登录后收到的GumpUser对象包含以下信息 |
| 151 | 151 | ||
| 152 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! | 152 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! |
| 153 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 | 153 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 |
| 154 | gumpUser.getSessionKey();//登录的sesionKey | 154 | gumpUser.getSessionKey();//登录的sesionKey |
| 155 | 155 | ||
| 156 | 156 | ||
| 157 | #### 3.支付功能 | 157 | #### 3.支付功能 |
| 158 | 1)使用gump通行证登录,其中除nick和roleId外所有参数为必传参数 | 158 | 1)使用gump通行证登录,其中除nick外所有参数为必传参数 |
| 159 | 159 | ||
| 160 | Bundle payInfo = new Bundle(); | 160 | Bundle payInfo = new Bundle(); |
| 161 | payInfo.putString("nick", "thi"); | 161 | payInfo.putString("nick", "thi"); |
| 162 | payInfo.putString("product", "元宝"); | 162 | payInfo.putString("product", "元宝"); |
| 163 | payInfo.putFloat("amount", 40.0f); | 163 | payInfo.putFloat("amount", 40.0f); |
| 164 | payInfo.putString("extraInfo", "This is demo!"); | 164 | payInfo.putString("extraInfo", "This is demo!"); |
| 165 | payInfo.putString("serverId", "B4003"); | 165 | payInfo.putString("serverId", "B4003"); |
| 166 | payInfo.putString("roleId", "10010"); | 166 | payInfo.putString("roleId", "10010"); |
| 167 | payInfo.putString("sessionKey","sessionkey"); | 167 | payInfo.putString("sessionKey","sessionkey"); |
| 168 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); | 168 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); |
| 169 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick和roleId外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey | 169 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick和roleId外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey |
| 170 | 170 | ||
| 171 | 171 | ||
| 172 | 2)IAP支付,roleId为可选参数,其他参数必传 | 172 | 2)IAP支付 |
| 173 | 173 | ||
| 174 | Bundle payInfo = new Bundle(); | 174 | Bundle payInfo = new Bundle(); |
| 175 | payInfo.putString("product", "gp_skuId"); | 175 | payInfo.putString("product", "gp_skuId"); |
| 176 | payInfo.putFloat("amount", 0.1f); | 176 | payInfo.putFloat("amount", 0.1f); |
| 177 | payInfo.putString("extraInfo", "This is demo!"); | 177 | payInfo.putString("extraInfo", "This is demo!"); |
| 178 | payInfo.putString("serverId", "100"); | 178 | payInfo.putString("serverId", "100"); |
| 179 | payInfo.putString("roleId","100123"); | 179 | payInfo.putString("roleId","100123"); |
| 180 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); | 180 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); |
| 181 | 181 | ||
| 182 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 | 182 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 |
| 183 | 183 | ||
| 184 | @Override | 184 | @Override |
| 185 | public void onPurchaseCompleted(PurchaseResult result) { | 185 | public void onPurchaseCompleted(PurchaseResult result) { |
| 186 | Log.i(TAG,"purchase completed"); | 186 | Log.i(TAG,"purchase completed"); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | @Override | 189 | @Override |
| 190 | public void onPurchaseError(int code, String msg) { | 190 | public void onPurchaseError(int code, String msg) { |
| 191 | Log.i(TAG,"purchase error"); | 191 | Log.i(TAG,"purchase error"); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | @Override | 194 | @Override |
| 195 | public void onPurchaseCanceled() { | 195 | public void onPurchaseCanceled() { |
| 196 | Log.i(TAG,"purchase canceled"); | 196 | Log.i(TAG,"purchase canceled"); |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | #### 4.注销登录 | 199 | #### 4.注销登录 |
| 200 | 200 | ||
| 201 | GumpSDK.logout(Activity); | 201 | GumpSDK.logout(Activity); |
| 202 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 | 202 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 |
| 203 | ## 第二章 常见问题 | 203 | ## 第二章 常见问题 |
| 204 | ### 问题1: 如何避免混淆对SDK的影响? | 204 | ### 问题1: 如何避免混淆对SDK的影响? |
| 205 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java | 205 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java |
| 206 | 类,导致SDK无法正常工作,解决方法如下: | 206 | 类,导致SDK无法正常工作,解决方法如下: |
| 207 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 | 207 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 |
| 208 | 208 | ||
| 209 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable | 209 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable |
| 210 | -keep public class * extends android.app.Service | 210 | -keep public class * extends android.app.Service |
| 211 | -keep public class com.google.vending.licensing.ILicensingService | 211 | -keep public class com.google.vending.licensing.ILicensingService |
| 212 | -keep public class com.android.vending.licensing.ILicensingService | 212 | -keep public class com.android.vending.licensing.ILicensingService |
| 213 | -keep class com.g.root.view.* {*;} | 213 | -keep class com.g.root.view.* {*;} |
| 214 | -keep class com.g.root.web.* {*;} | 214 | -keep class com.g.root.web.* {*;} |
| 215 | -keep class com.g.root.bridge.impl.*{*;} | 215 | -keep class com.g.root.bridge.impl.*{*;} |
| 216 | 216 | ||
| 217 | 217 | ||
| 218 | 使得混淆的时候不会影响SDK的命名空间。 | 218 | 使得混淆的时候不会影响SDK的命名空间。 |