Commit 472513368140a30aba3c79ba1ed96429c5b0bf46
1 parent
e5321be534
Exists in
master
取消游客绑定提醒
Showing 5 changed files with 26 additions and 23 deletions Inline Diff
GameSDKDemo/build.gradle
| 1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' | 
| 2 | 2 | ||
| 3 | /*gump test config,you could ignore it | 3 | /*gump test config,you could ignore it | 
| 4 | * gump打包测试使用,你可以自行配置,或者直接删除这部分内容 | 4 | * gump打包测试使用,你可以自行配置,或者直接删除这部分内容 | 
| 5 | */ | 5 | */ | 
| 6 | def keystorePSW = '' | 6 | def keystorePSW = '' | 
| 7 | def keystoreAlias = '' | 7 | def keystoreAlias = '' | 
| 8 | def keystoreAliasPSW = '' | 8 | def keystoreAliasPSW = '' | 
| 9 | // default keystore file, PLZ config file path in local.properties | 9 | // default keystore file, PLZ config file path in local.properties | 
| 10 | def keyfile = file('s.keystore.temp') | 10 | def keyfile = file('s.keystore.temp') | 
| 11 | 11 | ||
| 12 | Properties properties = new Properties() | 12 | Properties properties = new Properties() | 
| 13 | // local.properties file in the root director | 13 | // local.properties file in the root director | 
| 14 | properties.load(project.file('local.properties').newDataInputStream()) | 14 | properties.load(project.file('local.properties').newDataInputStream()) | 
| 15 | def keystoreFilepath = properties.getProperty("keystore.path") | 15 | def keystoreFilepath = properties.getProperty("keystore.path") | 
| 16 | 16 | ||
| 17 | if (keystoreFilepath) { | 17 | if (keystoreFilepath) { | 
| 18 | keystorePSW = properties.getProperty("keystore.password") | 18 | keystorePSW = properties.getProperty("keystore.password") | 
| 19 | keystoreAlias = properties.getProperty("keystore.alias") | 19 | keystoreAlias = properties.getProperty("keystore.alias") | 
| 20 | keystoreAliasPSW = properties.getProperty("keystore.key_passwd") | 20 | keystoreAliasPSW = properties.getProperty("keystore.key_passwd") | 
| 21 | keyfile = file(keystoreFilepath) | 21 | keyfile = file(keystoreFilepath) | 
| 22 | } | 22 | } | 
| 23 | /* | 23 | /* | 
| 24 | * gump test config,you could ignore it | 24 | * gump test config,you could ignore it | 
| 25 | * gump打包测试使用,你可以自行配置,或者直接删除这部分内容 | 25 | * gump打包测试使用,你可以自行配置,或者直接删除这部分内容 | 
| 26 | */ | 26 | */ | 
| 27 | 27 | ||
| 28 | repositories { | 28 | repositories { | 
| 29 | maven{ | 29 | maven{ | 
| 30 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" | 30 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" | 
| 31 | } | 31 | } | 
| 32 | jcenter() | 32 | jcenter() | 
| 33 | google() | 33 | google() | 
| 34 | } | 34 | } | 
| 35 | 35 | ||
| 36 | android { | 36 | android { | 
| 37 | compileSdkVersion 26 | 37 | compileSdkVersion 26 | 
| 38 | buildToolsVersion "27.0.3" | 38 | buildToolsVersion "27.0.3" | 
| 39 | 39 | ||
| 40 | signingConfigs { | 40 | signingConfigs { | 
| 41 | release { | 41 | release { | 
| 42 | storeFile keyfile | 42 | storeFile keyfile | 
| 43 | storePassword keystorePSW | 43 | storePassword keystorePSW | 
| 44 | keyPassword keystoreAliasPSW | 44 | keyPassword keystoreAliasPSW | 
| 45 | keyAlias keystoreAlias | 45 | keyAlias keystoreAlias | 
| 46 | } | 46 | } | 
| 47 | } | 47 | } | 
| 48 | 48 | ||
| 49 | defaultConfig { | 49 | defaultConfig { | 
| 50 | minSdkVersion 14 | 50 | minSdkVersion 14 | 
| 51 | targetSdkVersion 26 | 51 | targetSdkVersion 26 | 
| 52 | versionCode 5 | 52 | versionCode 5 | 
| 53 | versionName "1.3" | 53 | versionName "1.3" | 
| 54 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | 54 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | 
| 55 | signingConfig signingConfigs.release | 55 | signingConfig signingConfigs.release | 
| 56 | } | 56 | } | 
| 57 | buildTypes { | 57 | buildTypes { | 
| 58 | release { | 58 | release { | 
| 59 | minifyEnabled false | 59 | minifyEnabled false | 
| 60 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 60 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 
| 61 | zipAlignEnabled true | 61 | zipAlignEnabled true | 
| 62 | } | 62 | } | 
| 63 | debug { | 63 | debug { | 
| 64 | signingConfig signingConfigs.release | 64 | signingConfig signingConfigs.release | 
| 65 | } | 65 | } | 
| 66 | } | 66 | } | 
| 67 | lintOptions { | 67 | lintOptions { | 
| 68 | abortOnError false | 68 | abortOnError false | 
| 69 | } | 69 | } | 
| 70 | 70 | ||
| 71 | } | 71 | } | 
| 72 | 72 | ||
| 73 | dependencies { | 73 | dependencies { | 
| 74 | implementation fileTree(include: ['*.jar'], dir: 'libs') | 74 | implementation fileTree(include: ['*.jar'], dir: 'libs') | 
| 75 | testImplementation 'junit:junit:4.12' | 75 | testImplementation 'junit:junit:4.12' | 
| 76 | implementation 'com.android.support:appcompat-v7:26.1.0' | 76 | implementation 'com.android.support:appcompat-v7:26.1.0' | 
| 77 | //微信 | 77 | //微信 | 
| 78 | implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.1.4' | 78 | implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.1.4' | 
| 79 | //VK | 79 | //VK | 
| 80 | implementation 'com.gumptech:VKsdk:1.5.4' | 80 | implementation 'com.gumptech:VKsdk:1.5.4' | 
| 81 | // implementation project(':GameSDK') | 81 | // implementation project(':GameSDK') | 
| 82 | implementation 'com.gumptech.sdk:GameSDK:4.5.0' | 82 | implementation 'com.gumptech.sdk:GameSDK:4.5.3' | 
| 83 | } | 83 | } | 
| 84 | 84 | 
GameSDKDemo/src/main/AndroidManifest.xml
| 1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 
| 2 | package="com.gumptech.sdk.demo"> | 2 | package="com.gumptech.sdk.demo"> | 
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | <uses-sdk | 5 | <uses-sdk | 
| 6 | android:minSdkVersion="9" | 6 | android:minSdkVersion="9" | 
| 7 | android:targetSdkVersion="23"/> | 7 | android:targetSdkVersion="23"/> | 
| 8 | 8 | ||
| 9 | <uses-permission android:name="android.permission.INTERNET"/> | 9 | <uses-permission android:name="android.permission.INTERNET"/> | 
| 10 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | 10 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | 
| 11 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | 11 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | 
| 12 | <!-- Danger Level permission--> | 12 | <!-- Danger Level permission--> | 
| 13 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | 13 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | 
| 14 | <uses-permission android:name="android.permission.GET_ACCOUNTS"/> | 14 | <uses-permission android:name="android.permission.GET_ACCOUNTS"/> | 
| 15 | 15 | ||
| 16 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 16 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 
| 17 | <uses-permission android:name="com.android.vending.BILLING"/> | 17 | <uses-permission android:name="com.android.vending.BILLING"/> | 
| 18 | 18 | ||
| 19 | <application | 19 | <application | 
| 20 | android:allowBackup="true" | 20 | android:allowBackup="true" | 
| 21 | android:icon="@drawable/ic_launcher" | 21 | android:icon="@drawable/ic_launcher" | 
| 22 | android:label="@string/app_name"> | 22 | android:label="@string/app_name"> | 
| 23 | <activity | 23 | <activity | 
| 24 | android:name="com.gumptech.sdk.demo.MainActivity" | 24 | android:name="com.gumptech.sdk.demo.MainActivity" | 
| 25 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 25 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 
| 26 | android:label="@string/app_name" | 26 | android:label="@string/app_name" | 
| 27 | android:screenOrientation="portrait"> | 27 | android:screenOrientation="landscape"> | 
| 28 | <intent-filter> | 28 | <intent-filter> | 
| 29 | <action android:name="android.intent.action.MAIN"/> | 29 | <action android:name="android.intent.action.MAIN"/> | 
| 30 | 30 | ||
| 31 | <category android:name="android.intent.category.LAUNCHER"/> | 31 | <category android:name="android.intent.category.LAUNCHER"/> | 
| 32 | </intent-filter> | 32 | </intent-filter> | 
| 33 | </activity> | 33 | </activity> | 
| 34 | <activity | 34 | <activity | 
| 35 | android:name="com.gumptech.sdk.ContainerActivity" | 35 | android:name="com.gumptech.sdk.ContainerActivity" | 
| 36 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 36 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 
| 37 | android:launchMode="singleTask" | 37 | android:launchMode="singleTask" | 
| 38 | android:theme="@style/Theme.TransparentWin" | 38 | android:theme="@style/Theme.TransparentWin" | 
| 39 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> | 39 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> | 
| 40 | </activity> | 40 | </activity> | 
| 41 | <activity | 41 | <activity | 
| 42 | android:name="com.gumptech.sdk.PaymentActivity" | 42 | android:name="com.gumptech.sdk.PaymentActivity" | 
| 43 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 43 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 
| 44 | android:theme="@android:style/Theme.Light.NoTitleBar" | 44 | android:launchMode="singleTask" | 
| 45 | android:launchMode="singleTask"> | 45 | android:theme="@android:style/Theme.Light.NoTitleBar"> | 
| 46 | <intent-filter> | 46 | <intent-filter> | 
| 47 | <category android:name="android.intent.category.DEFAULT"/> | 47 | <category android:name="android.intent.category.DEFAULT"/> | 
| 48 | 48 | ||
| 49 | <action android:name="android.intent.action.VIEW"/> | 49 | <action android:name="android.intent.action.VIEW"/> | 
| 50 | 50 | ||
| 51 | <category android:name="android.intent.category.BROWSABLE"/> | 51 | <category android:name="android.intent.category.BROWSABLE"/> | 
| 52 | 52 | ||
| 53 | <data | 53 | <data | 
| 54 | android:host="com.gump.sdk" | 54 | android:host="com.gump.sdk" | 
| 55 | android:scheme="gump10031"/> | 55 | android:scheme="gump10031"/> | 
| 56 | </intent-filter> | 56 | </intent-filter> | 
| 57 | </activity> | 57 | </activity> | 
| 58 | <activity | 58 | <activity | 
| 59 | android:name="com.gumptech.sdk.ExchangeWindow" | 59 | android:name="com.gumptech.sdk.ExchangeWindow" | 
| 60 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 60 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 
| 61 | android:theme="@style/Theme.WinForExchange"> | 61 | android:theme="@style/Theme.WinForExchange"> | 
| 62 | </activity> | 62 | </activity> | 
| 63 | 63 | ||
| 64 | <service android:name="com.gumptech.sdk.PushService"> | 64 | <service android:name="com.gumptech.sdk.PushService"> | 
| 65 | </service> | 65 | </service> | 
| 66 | 66 | ||
| 67 | <!--wechat--> | 67 | <!--wechat--> | 
| 68 | <activity | 68 | <activity | 
| 69 | android:name=".wxapi.WXEntryActivity" | 69 | android:name=".wxapi.WXEntryActivity" | 
| 70 | android:exported="true"></activity> | 70 | android:exported="true"></activity> | 
| 71 | <!-- vk --> | 71 | <!-- vk --> | 
| 72 | <!-- <activity android:name="com.vk.com.gumptech.sdk.VKOpenAuthActivity" /> --> | 72 | <!-- <activity android:name="com.vk.com.gumptech.sdk.VKOpenAuthActivity" /> --> | 
| 73 | <!-- <activity --> | 73 | <!-- <activity --> | 
| 74 | <!-- android:name="com.vk.com.gumptech.sdk.VKServiceActivity" --> | 74 | <!-- android:name="com.vk.com.gumptech.sdk.VKServiceActivity" --> | 
| 75 | <!-- android:label="ServiceActivity" --> | 75 | <!-- android:label="ServiceActivity" --> | 
| 76 | <!-- android:theme="@style/VK.Transparent" /> --> | 76 | <!-- android:theme="@style/VK.Transparent" /> --> | 
| 77 | </application> | 77 | </application> | 
| 78 | 78 | ||
| 79 | 79 | ||
| 80 | </manifest> | 80 | </manifest> | 
| 81 | 81 | 
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.os.Bundle; | 4 | import android.os.Bundle; | 
| 5 | import android.util.Log; | 5 | import android.util.Log; | 
| 6 | import android.view.View; | 6 | import android.view.View; | 
| 7 | import android.widget.Button; | 7 | import android.widget.Button; | 
| 8 | import android.widget.TextView; | 8 | import android.widget.TextView; | 
| 9 | import android.widget.Toast; | 9 | import android.widget.Toast; | 
| 10 | 10 | ||
| 11 | import com.gumptech.sdk.GumpPreference; | 11 | import com.gumptech.sdk.GumpPreference; | 
| 12 | import com.gumptech.sdk.GumpSDK; | 12 | import com.gumptech.sdk.GumpSDK; | 
| 13 | import com.gumptech.sdk.PaymentVersion; | 13 | import com.gumptech.sdk.PaymentVersion; | 
| 14 | import com.gumptech.sdk.SDKSettings; | 14 | import com.gumptech.sdk.SDKSettings; | 
| 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.gumptech.sdk.callback.ResultCallback; | 20 | import com.gumptech.sdk.callback.ResultCallback; | 
| 21 | import com.gumptech.sdk.passport.fb.FBAccessToken; | 21 | import com.gumptech.sdk.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 = "100"; | 32 | private String appId = "100"; | 
| 33 | private String appKey = "f899139df5e1059396431415e770c6dd"; | 33 | private String appKey = "f899139df5e1059396431415e770c6dd"; | 
| 34 | private GumpUser gumpUser; | 34 | private GumpUser gumpUser; | 
| 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 | 41 | ||
| 42 | tvVersion = (TextView) findViewById(R.id.version); | 42 | tvVersion = (TextView) findViewById(R.id.version); | 
| 43 | userInfo = (TextView) findViewById(R.id.user_info); | 43 | userInfo = (TextView) findViewById(R.id.user_info); | 
| 44 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); | 44 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); | 
| 45 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | 45 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | 
| 46 | 46 | ||
| 47 | @Override | 47 | @Override | 
| 48 | public void onClick(View v) { | 48 | public void onClick(View v) { | 
| 49 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | 49 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | 
| 50 | GumpSDK.start(MainActivity.this); | 50 | GumpSDK.start(MainActivity.this); | 
| 51 | else | 51 | else | 
| 52 | GumpSDK.logout(MainActivity.this); | 52 | GumpSDK.logout(MainActivity.this); | 
| 53 | } | 53 | } | 
| 54 | }); | 54 | }); | 
| 55 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | 55 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | 
| 56 | 56 | ||
| 57 | @Override | 57 | @Override | 
| 58 | public void onClick(View v) { | 58 | public void onClick(View v) { | 
| 59 | Bundle payInfo = new Bundle(); | 59 | Bundle payInfo = new Bundle(); | 
| 60 | payInfo.putString("product", "wa2"); | 60 | payInfo.putString("product", "wa2"); | 
| 61 | payInfo.putFloat("amount", 0.1f); | 61 | payInfo.putFloat("amount", 0.1f); | 
| 62 | payInfo.putString("extraInfo", "This is demo!"); | 62 | payInfo.putString("extraInfo", "This is demo!"); | 
| 63 | payInfo.putString("serverId", "s1"); | 63 | payInfo.putString("serverId", "s1"); | 
| 64 | payInfo.putString("roleId", "100123"); | 64 | payInfo.putString("roleId", "100123"); | 
| 65 | payInfo.putString("sessionKey", gumpUser.getSessionKey().getToken()); | 65 | payInfo.putString("sessionKey", gumpUser.getSessionKey().getToken()); | 
| 66 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); | 66 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); | 
| 67 | } | 67 | } | 
| 68 | }); | 68 | }); | 
| 69 | findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { | 69 | findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { | 
| 70 | @Override | 70 | @Override | 
| 71 | public void onClick(View v) { | 71 | public void onClick(View v) { | 
| 72 | Bundle payInfo = new Bundle(); | 72 | Bundle payInfo = new Bundle(); | 
| 73 | payInfo.putString("product", "180010"); | 73 | payInfo.putString("product", "180010"); | 
| 74 | payInfo.putFloat("amount", 0.1f); | 74 | payInfo.putFloat("amount", 0.1f); | 
| 75 | payInfo.putString("extraInfo", "This is demo!"); | 75 | payInfo.putString("extraInfo", "This is demo!"); | 
| 76 | payInfo.putString("serverId", "100"); | 76 | payInfo.putString("serverId", "100"); | 
| 77 | payInfo.putString("roleId", "100123"); | 77 | payInfo.putString("roleId", "100123"); | 
| 78 | GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); | 78 | GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); | 
| 79 | } | 79 | } | 
| 80 | }); | 80 | }); | 
| 81 | 81 | ||
| 82 | |||
| 82 | GumpSDK.getSettings().setDebug(false); | 83 | GumpSDK.getSettings().setDebug(false); | 
| 83 | /** | 84 | /** | 
| 84 | * 设置否是打印debug日志 | 85 | * 设置否是打印debug日志 | 
| 85 | */ | 86 | */ | 
| 86 | GumpSDK.getSettings().enableDebugLogging(true); | 87 | GumpSDK.getSettings().enableDebugLogging(true); | 
| 87 | /** | 88 | /** | 
| 88 | * 设置启用facebook登录 | 89 | * 设置启用facebook登录 | 
| 89 | */ | 90 | */ | 
| 90 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_FB); | 91 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_FB); | 
| 91 | /** | 92 | /** | 
| 92 | * 设置启用Vk登录 | 93 | * 设置启用Vk登录 | 
| 93 | */ | 94 | */ | 
| 94 | // GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_VK); | 95 | // GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_VK); | 
| 95 | 96 | ||
| 96 | /** | 97 | /** | 
| 97 | * 设置启用Wechat登录 | 98 | * 设置启用Wechat登录 | 
| 98 | * | 99 | * | 
| 99 | */ | 100 | */ | 
| 100 | // GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_WECHAT); | 101 | // GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_WECHAT); | 
| 101 | 102 | ||
| 102 | /** | 103 | /** | 
| 103 | * 设置启用google登录 | 104 | * 设置启用google登录 | 
| 104 | */ | 105 | */ | 
| 105 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_GOOGLE); | 106 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_GOOGLE); | 
| 106 | 107 | ||
| 107 | /** | 108 | /** | 
| 108 | * 设置启用Line登录 | 109 | * 设置启用Line登录 | 
| 109 | */ | 110 | */ | 
| 110 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_LINE); | 111 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_LINE); | 
| 111 | /** | 112 | /** | 
| 112 | * 设置屏幕方向 | 113 | * 设置屏幕方向 | 
| 113 | */ | 114 | */ | 
| 114 | GumpSDK.getSettings().setScreenLandscape(true); | 115 | GumpSDK.getSettings().setScreenLandscape(true); | 
| 115 | 116 | ||
| 116 | /** | 117 | /** | 
| 117 | * 设置支付版本 | 118 | * 设置支付版本 | 
| 118 | */ | 119 | */ | 
| 119 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | 120 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | 
| 120 | 121 | ||
| 121 | /** | 122 | /** | 
| 122 | * 设置用户登录状态监听器 | 123 | * 设置用户登录状态监听器 | 
| 123 | */ | 124 | */ | 
| 124 | 125 | ||
| 125 | GumpSDK.setUserStateListener(new LoginStateListener() { | 126 | GumpSDK.setUserStateListener(new LoginStateListener() { | 
| 126 | @Override | 127 | @Override | 
| 127 | public void onLoginSuccess(GumpUser user) { | 128 | public void onLoginSuccess(GumpUser user) { | 
| 128 | gumpUser = user; | 129 | gumpUser = user; | 
| 129 | String userType = null; | 130 | String userType = null; | 
| 130 | switch (user.getAccountType()) { | 131 | switch (user.getAccountType()) { | 
| 131 | case GumpPreference.ACCOUNT_TYPE_FB: | 132 | case GumpPreference.ACCOUNT_TYPE_FB: | 
| 132 | userType = "Facebook登录"; | 133 | userType = "Facebook登录"; | 
| 133 | String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); | 134 | String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); | 
| 134 | Log.d(TAG, "FBAccessToken:" + fbToken); | 135 | Log.d(TAG, "FBAccessToken:" + fbToken); | 
| 135 | break; | 136 | break; | 
| 136 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | 137 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | 
| 137 | userType = "快速登录"; | 138 | userType = "快速登录"; | 
| 138 | break; | 139 | break; | 
| 139 | case GumpPreference.ACCOUNT_TYPE_REG: | 140 | case GumpPreference.ACCOUNT_TYPE_REG: | 
| 140 | userType = "gump注册用户"; | 141 | userType = "gump注册用户"; | 
| 141 | break; | 142 | break; | 
| 142 | case GumpPreference.ACCOUNT_TYPE_VK: | 143 | case GumpPreference.ACCOUNT_TYPE_VK: | 
| 143 | userType = "vk登录"; | 144 | userType = "vk登录"; | 
| 144 | break; | 145 | break; | 
| 145 | case GumpPreference.ACCOUNT_TYPE_GOOGLE: | 146 | case GumpPreference.ACCOUNT_TYPE_GOOGLE: | 
| 146 | userType = "google 登录"; | 147 | userType = "google 登录"; | 
| 147 | break; | 148 | break; | 
| 148 | case GumpPreference.ACCOUNT_TYPE_WECHAT: | 149 | case GumpPreference.ACCOUNT_TYPE_WECHAT: | 
| 149 | userType = "微信登录"; | 150 | userType = "微信登录"; | 
| 150 | break; | 151 | break; | 
| 151 | case GumpPreference.ACCOUNT_TYPE_LINE: | 152 | case GumpPreference.ACCOUNT_TYPE_LINE: | 
| 152 | userType = "Line登录"; | 153 | userType = "Line登录"; | 
| 153 | break; | 154 | break; | 
| 154 | } | 155 | } | 
| 155 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey().getToken()); | 156 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey() | 
| 157 | .getToken()); | ||
| 156 | btnLoginOrLogout.setText("Logout"); | 158 | btnLoginOrLogout.setText("Logout"); | 
| 157 | btnLoginOrLogout.setTag(1); | 159 | btnLoginOrLogout.setTag(1); | 
| 158 | } | 160 | } | 
| 159 | 161 | ||
| 160 | @Override | 162 | @Override | 
| 161 | public void onLoginFailed(int code, String msg) { | 163 | public void onLoginFailed(int code, String msg) { | 
| 162 | userInfo.setText(msg); | 164 | userInfo.setText(msg); | 
| 163 | Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); | 165 | Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); | 
| 164 | } | 166 | } | 
| 165 | 167 | ||
| 166 | @Override | 168 | @Override | 
| 167 | public void onLoginCanceled() { | 169 | public void onLoginCanceled() { | 
| 168 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 170 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 
| 169 | } | 171 | } | 
| 170 | 172 | ||
| 171 | @Override | 173 | @Override | 
| 172 | public void onLogout() { | 174 | public void onLogout() { | 
| 173 | btnLoginOrLogout.setText("Login"); | 175 | btnLoginOrLogout.setText("Login"); | 
| 174 | btnLoginOrLogout.setTag(0); | 176 | btnLoginOrLogout.setTag(0); | 
| 175 | userInfo.setText("User is logout"); | 177 | userInfo.setText("User is logout"); | 
| 176 | } | 178 | } | 
| 177 | 179 | ||
| 178 | @Override | 180 | @Override | 
| 179 | public void onPermissionDenied() { | 181 | public void onPermissionDenied() { | 
| 180 | 182 | ||
| 181 | } | 183 | } | 
| 182 | }); | 184 | }); | 
| 183 | /** | 185 | /** | 
| 184 | * 初始化sdk | 186 | * 初始化sdk | 
| 185 | */ | 187 | */ | 
| 186 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { | 188 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { | 
| 187 | @Override | 189 | @Override | 
| 188 | public void initComplete(int result) { | 190 | public void initComplete(int result) { | 
| 189 | if (result == GumpSDK.CODE.OK) { | 191 | if (result == GumpSDK.CODE.OK) { | 
| 190 | btnLoginOrLogout.setEnabled(true); | 192 | btnLoginOrLogout.setEnabled(true); | 
| 191 | 193 | ||
| 192 | //checkRisk(); | 194 | //checkRisk(); | 
| 193 | } | 195 | } | 
| 194 | } | 196 | } | 
| 195 | }); | 197 | }); | 
| 196 | 198 | ||
| 197 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | 199 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | 
| 198 | 200 | ||
| 199 | } | 201 | } | 
| 200 | 202 | ||
| 201 | private void checkRisk() { | 203 | private void checkRisk() { | 
| 202 | GumpSDK.checkRisk(this, new ResultCallback() { | 204 | GumpSDK.checkRisk(this, new ResultCallback() { | 
| 203 | @Override | 205 | @Override | 
| 204 | public void onResult(boolean isRisk) { | 206 | public void onResult(boolean isRisk) { | 
| 205 | Log.i(TAG, isRisk ? "There is some risks" : "Nothing is risk"); | 207 | Log.i(TAG, isRisk ? "There is some risks" : "Nothing is risk"); | 
| 206 | } | 208 | } | 
| 207 | }); | 209 | }); | 
| 208 | } | 210 | } | 
| 209 | 211 | ||
| 210 | @Override | 212 | @Override | 
| 211 | public void onPurchaseCompleted(PurchaseResult result) { | 213 | public void onPurchaseCompleted(PurchaseResult result) { | 
| 212 | Log.i(TAG, "purchase completed"); | 214 | Log.i(TAG, "purchase completed"); | 
| 213 | } | 215 | } | 
| 214 | 216 | ||
| 215 | @Override | 217 | @Override | 
| 216 | public void onPurchaseError(int code, String msg) { | 218 | public void onPurchaseError(int code, String msg) { | 
| 217 | Log.i(TAG, "purchase error"); | 219 | Log.i(TAG, "purchase error"); | 
| 218 | } | 220 | } | 
| 219 | 221 | ||
| 220 | @Override | 222 | @Override | 
| 221 | public void onPurchaseCanceled() { | 223 | public void onPurchaseCanceled() { | 
| 222 | Log.i(TAG, "purchase canceled"); | 224 | Log.i(TAG, "purchase canceled"); | 
| 223 | } | 225 | } | 
| 224 | 226 | ||
| 225 | 227 | ||
| 226 | } | 228 | } | 
| 227 | 229 | 
GameSDKDemo/src/main/res/layout/activity_main.xml
| 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 
| 2 | android:layout_width="match_parent" | 2 | android:layout_width="match_parent" | 
| 3 | android:layout_height="match_parent" | 3 | android:layout_height="match_parent" | 
| 4 | android:background="@android:color/white" | 4 | android:background="@android:color/white" | 
| 5 | android:fitsSystemWindows="true" | 5 | android:fitsSystemWindows="true" | 
| 6 | android:orientation="vertical"> | 6 | android:orientation="vertical"> | 
| 7 | 7 | ||
| 8 | <TextView | 8 | <TextView | 
| 9 | android:id="@+id/version" | 9 | android:id="@+id/version" | 
| 10 | android:layout_width="wrap_content" | 10 | android:layout_width="wrap_content" | 
| 11 | android:layout_height="wrap_content" | 11 | android:layout_height="wrap_content" | 
| 12 | android:layout_gravity="center_horizontal" | 12 | android:layout_gravity="center_horizontal" | 
| 13 | android:textColor="@color/black_text"/> | 13 | android:textColor="@color/black_text"/> | 
| 14 | 14 | ||
| 15 | <TextView | 15 | <TextView | 
| 16 | android:id="@+id/user_info" | 16 | android:id="@+id/user_info" | 
| 17 | android:layout_width="match_parent" | 17 | android:layout_width="match_parent" | 
| 18 | android:layout_height="wrap_content" | 18 | android:layout_height="wrap_content" | 
| 19 | android:textColor="@android:color/black"/> | 19 | android:textColor="@android:color/black"/> | 
| 20 | 20 | ||
| 21 | <Button | 21 | <Button | 
| 22 | android:id="@+id/login_or_logout" | 22 | android:id="@+id/login_or_logout" | 
| 23 | android:layout_width="match_parent" | 23 | android:layout_width="match_parent" | 
| 24 | android:layout_height="wrap_content" | 24 | android:layout_height="wrap_content" | 
| 25 | android:backgroundTint="@color/g_color" | 25 | android:backgroundTint="@color/g_color" | 
| 26 | android:enabled="false" | 26 | android:enabled="false" | 
| 27 | android:text="Login"/> | 27 | android:text="Login"/> | 
| 28 | 28 | ||
| 29 | <Button | 29 | <Button | 
| 30 | android:id="@+id/iap" | 30 | android:id="@+id/iap" | 
| 31 | android:layout_width="match_parent" | 31 | android:layout_width="match_parent" | 
| 32 | android:layout_height="wrap_content" | 32 | android:layout_height="wrap_content" | 
| 33 | android:backgroundTint="@color/g_color" | 33 | android:backgroundTint="@color/g_color" | 
| 34 | android:text="IAP"/> | 34 | android:text="IAP"/> | 
| 35 | 35 | ||
| 36 | <Button | 36 | <Button | 
| 37 | android:id="@+id/pay" | 37 | android:id="@+id/pay" | 
| 38 | android:layout_width="match_parent" | 38 | android:layout_width="match_parent" | 
| 39 | android:layout_height="wrap_content" | 39 | android:layout_height="wrap_content" | 
| 40 | android:backgroundTint="@color/g_color" | 40 | android:backgroundTint="@color/g_color" | 
| 41 | android:text="pay"/> | 41 | android:text="pay"/> | 
| 42 | 42 | ||
| 43 | |||
| 43 | </LinearLayout> | 44 | </LinearLayout> | 
README.md
| 1 | # Gump SDK 4 for Android接入文档 | 1 | # Gump SDK 4 for Android接入文档 | 
| 2 | 2 | ||
| 3 | V4.5.1 | 3 | V4.5.3 | 
| 4 | 2018年7月13日 | 4 | 2018年8月21日 | 
| 5 | 5 | ||
| 6 | ## 版本概述 | 6 | ## 版本概述 | 
| 7 | 7 | ||
| 8 | 此版本为使用AndroidStudio开发的版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. | 8 | 此版本为使用AndroidStudio开发的版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. | 
| 9 | 9 | ||
| 10 | 此SDK适用android4.0以上系统. | 10 | 此SDK适用android4.0以上系统. | 
| 11 | 11 | ||
| 12 | ## 第一章 接入指南 | 12 | ## 第一章 接入指南 | 
| 13 | ### 1.依赖导入 | 13 | ### 1.依赖导入 | 
| 14 | 配置gradle,以下为必须项 | 14 | 配置gradle,以下为必须项 | 
| 15 | 15 | ||
| 16 | repositories{ | 16 | repositories{ | 
| 17 | maven{ | 17 | maven{ | 
| 18 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" | 18 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" | 
| 19 | } | 19 | } | 
| 20 | } | 20 | } | 
| 21 | dependencies { | 21 | dependencies { | 
| 22 | implementation 'com.gumptech.sdk:GameSDK:4.5.1' | 22 | implementation 'com.gumptech.sdk:GameSDK:4.5.3' | 
| 23 | } | 23 | } | 
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 可选接入vk登录时,需要导入vkLibrary工程,并配置模块依赖,如下 | 26 | 可选接入vk登录时,需要导入vkLibrary工程,并配置模块依赖,如下 | 
| 27 | 27 | ||
| 28 | implementation 'com.gumptech:VKsdk:1.5.4' | 28 | implementation 'com.gumptech:VKsdk:1.5.4' | 
| 29 | 29 | ||
| 30 | 选择接入微信登录时,需要增加微信依赖,如下: | 30 | 选择接入微信登录时,需要增加微信依赖,如下: | 
| 31 | 31 | ||
| 32 | implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.1.4' | 32 | implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.1.4' | 
| 33 | 33 | ||
| 34 | ### 2.修改AndroidManifest.xml文件 | 34 | ### 2.修改AndroidManifest.xml文件 | 
| 35 | 首先添加必要的权限,如下所示: | 35 | 首先添加必要的权限,如下所示: | 
| 36 | 36 | ||
| 37 | <uses-permission android:name="android.permission.INTERNET" /> | 37 | <uses-permission android:name="android.permission.INTERNET" /> | 
| 38 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 38 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 
| 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 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 42 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 
| 43 | <uses-permission android:name="com.android.vending.BILLING" /> | 43 | <uses-permission android:name="com.android.vending.BILLING" /> | 
| 44 | 44 | ||
| 45 | 其次注册相应的Activity,具体如下: | 45 | 其次注册相应的Activity,具体如下: | 
| 46 | 46 | ||
| 47 | <activity | 47 | <activity | 
| 48 | android:name="com.gumptech.sdk.ContainerActivity" | 48 | android:name="com.gumptech.sdk.ContainerActivity" | 
| 49 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 49 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 
| 50 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan" | 50 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan" | 
| 51 | android:launchMode="singleTask" | 51 | android:launchMode="singleTask" | 
| 52 | android:theme="@style/Theme.TransparentWin" > | 52 | android:theme="@style/Theme.TransparentWin" > | 
| 53 | </activity> | 53 | </activity> | 
| 54 | <activity | 54 | <activity | 
| 55 | android:name="com.gumptech.sdk.PaymentActivity" | 55 | android:name="com.gumptech.sdk.PaymentActivity" | 
| 56 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 56 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 
| 57 | android:launchMode="singleTask" | 57 | android:launchMode="singleTask" | 
| 58 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > | 58 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > | 
| 59 | <intent-filter> | 59 | <intent-filter> | 
| 60 | <category android:name="android.intent.category.DEFAULT" /> | 60 | <category android:name="android.intent.category.DEFAULT" /> | 
| 61 | <action android:name="android.intent.action.VIEW" /> | 61 | <action android:name="android.intent.action.VIEW" /> | 
| 62 | <category android:name="android.intent.category.BROWSABLE" /> | 62 | <category android:name="android.intent.category.BROWSABLE" /> | 
| 63 | <data | 63 | <data | 
| 64 | android:host="com.gump.sdk" | 64 | android:host="com.gump.sdk" | 
| 65 | android:scheme="gump+游戏的appId" /> | 65 | android:scheme="gump+游戏的appId" /> | 
| 66 | </intent-filter> | 66 | </intent-filter> | 
| 67 | </activity> | 67 | </activity> | 
| 68 | <activity | 68 | <activity | 
| 69 | android:name="com.gumptech.sdk.ExchangeWindow" | 69 | android:name="com.gumptech.sdk.ExchangeWindow" | 
| 70 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 70 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 
| 71 | android:theme="@style/Theme.WinForExchange" > | 71 | android:theme="@style/Theme.WinForExchange" > | 
| 72 | </activity> | 72 | </activity> | 
| 73 | 73 | ||
| 74 | <service android:name="com.gumptech.sdk.PushService" /> | 74 | <service android:name="com.gumptech.sdk.PushService" /> | 
| 75 | 75 | ||
| 76 | <!-- vk登录使用,若不接入vk,不需配置 --> | 76 | <!-- vk登录使用,若不接入vk,不需配置 --> | 
| 77 | <activity android:name="com.vk.sdk.VKOpenAuthActivity" /> | 77 | <activity android:name="com.vk.sdk.VKOpenAuthActivity" /> | 
| 78 | <activity | 78 | <activity | 
| 79 | android:name="com.vk.sdk.VKServiceActivity" | 79 | android:name="com.vk.sdk.VKServiceActivity" | 
| 80 | android:label="ServiceActivity" | 80 | android:label="ServiceActivity" | 
| 81 | android:theme="@style/VK.Transparent" /> | 81 | android:theme="@style/VK.Transparent" /> | 
| 82 | <!--wechat接入使用,不接入不需要配置--> | 82 | <!--wechat接入使用,不接入不需要配置--> | 
| 83 | <activity | 83 | <activity | 
| 84 | android:name=".wxapi.WXEntryActivity" | 84 | android:name=".wxapi.WXEntryActivity" | 
| 85 | android:exported="true"></activity> | 85 | android:exported="true"></activity> | 
| 86 | 86 | ||
| 87 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 | 87 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 | 
| 88 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 | 88 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 | 
| 89 | 89 | ||
| 90 | *是否打印debug日志 | 90 | *是否打印debug日志 | 
| 91 | 91 | ||
| 92 | GumpSDK.getSettings().enableDebugLogging(true); | 92 | GumpSDK.getSettings().enableDebugLogging(true); | 
| 93 | 93 | ||
| 94 | *横竖屏控制,默认为横屏,参数为false即为竖屏 | 94 | *横竖屏控制,默认为横屏,参数为false即为竖屏 | 
| 95 | 95 | ||
| 96 | GumpSDK.getSettings().setScreenLandscape(true); | 96 | GumpSDK.getSettings().setScreenLandscape(true); | 
| 97 | 97 | ||
| 98 | *设置需要启用的第三方登录,参数可选类型见第二章:[第三方登录平台](http://repository.gumptech.com:81/document/gamesdk4-android/blob/master/IntegrationGuide.md#1-third_plat) 字段说明 | 98 | *设置需要启用的第三方登录,参数可选类型见第二章:[第三方登录平台](http://repository.gumptech.com:81/document/gamesdk4-android/blob/master/IntegrationGuide.md#1-third_plat) 字段说明 | 
| 99 | 99 | ||
| 100 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_*); | 100 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_*); | 
| 101 | 101 | ||
| 102 | *若要使用V4版支付请设置 | 102 | *若要使用V4版支付请设置 | 
| 103 | 103 | ||
| 104 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | 104 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | 
| 105 | 105 | ||
| 106 | #### 1.调用GumpSDK前需要执行初始化。 | 106 | #### 1.调用GumpSDK前需要执行初始化。 | 
| 107 | 107 | ||
| 108 | 若不需要分渠道 | 108 | 若不需要分渠道 | 
| 109 | 109 | ||
| 110 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); | 110 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); | 
| 111 | 如果需要定义渠道,必须使用如下方法 | 111 | 如果需要定义渠道,必须使用如下方法 | 
| 112 | 112 | ||
| 113 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); | 113 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); | 
| 114 | 114 | ||
| 115 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 | 115 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 | 
| 116 | 116 | ||
| 117 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | 117 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | 
| 118 | 118 | ||
| 119 | GumpSDK.start(Activity); | 119 | GumpSDK.start(Activity); | 
| 120 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: | 120 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: | 
| 121 | 121 | ||
| 122 | GumpSDK.setUserStateListener(new LoginStateListener() { | 122 | GumpSDK.setUserStateListener(new LoginStateListener() { | 
| 123 | @Override | 123 | @Override | 
| 124 | public void onLoginSuccess(GumpUser gumpUser) { | 124 | public void onLoginSuccess(GumpUser gumpUser) { | 
| 125 | //登录成功,用户信息包含在GumpUser对象里 | 125 | //登录成功,用户信息包含在GumpUser对象里 | 
| 126 | } | 126 | } | 
| 127 | 127 | ||
| 128 | @Override | 128 | @Override | 
| 129 | public void onLoginFailed(int code, String msg) { | 129 | public void onLoginFailed(int code, String msg) { | 
| 130 | //登录出错,根据错误码和信息判断错误类型 | 130 | //登录出错,根据错误码和信息判断错误类型 | 
| 131 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | 131 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | 
| 132 | } | 132 | } | 
| 133 | 133 | ||
| 134 | @Override | 134 | @Override | 
| 135 | public void onLoginCanceled() { | 135 | public void onLoginCanceled() { | 
| 136 | //用户取消登录 | 136 | //用户取消登录 | 
| 137 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 137 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 
| 138 | } | 138 | } | 
| 139 | 139 | ||
| 140 | @Override | 140 | @Override | 
| 141 | public void onLogout() { | 141 | public void onLogout() { | 
| 142 | //用户登出 | 142 | //用户登出 | 
| 143 | 143 | ||
| 144 | } | 144 | } | 
| 145 | @Override | 145 | @Override | 
| 146 | public void onPermissionDenied() { | 146 | public void onPermissionDenied() { | 
| 147 | //用户拒绝授予权限 | 147 | //用户拒绝授予权限 | 
| 148 | } | 148 | } | 
| 149 | }); | 149 | }); | 
| 150 | 150 | ||
| 151 | 如上成功登录后收到的GumpUser对象包含以下信息 | 151 | 如上成功登录后收到的GumpUser对象包含以下信息 | 
| 152 | 152 | ||
| 153 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! | 153 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! | 
| 154 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 | 154 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 | 
| 155 | gumpUser.getSessionKey();//登录的sessionKey对象,获取sessionKey字符串请使用此对象的getToken()方法 | 155 | gumpUser.getSessionKey();//登录的sessionKey对象,获取sessionKey字符串请使用此对象的getToken()方法 | 
| 156 | 156 | ||
| 157 | ***注意:若需要使用微信登录,需要在packageName.wxapi下增加一个名为WXEntryActivity并继承com.gumptech.sdk.WXCallbackActivity的Activity,并参考AndroidManifest.xml设置的说明,做相应的配置,packageName为应用的包名,此Activity不须任何实现。*** | 157 | ***注意:若需要使用微信登录,需要在packageName.wxapi下增加一个名为WXEntryActivity并继承com.gumptech.sdk.WXCallbackActivity的Activity,并参考AndroidManifest.xml设置的说明,做相应的配置,packageName为应用的包名,此Activity不须任何实现。*** | 
| 158 | 158 | ||
| 159 | ***以GumpSDKDemo为例,包名为com.gumptech.sdk.demo,则WXEntryActivity的完整包路径为:com.gumptech.sdk.demo.wxapi.WXEntryActivity*** | 159 | ***以GumpSDKDemo为例,包名为com.gumptech.sdk.demo,则WXEntryActivity的完整包路径为:com.gumptech.sdk.demo.wxapi.WXEntryActivity*** | 
| 160 | 160 | ||
| 161 | #### 3.支付功能 | 161 | #### 3.支付功能 | 
| 162 | 1)使用gump通行证登录,其中除nick外所有参数为必传参数 | 162 | 1)使用gump通行证登录,其中除nick外所有参数为必传参数 | 
| 163 | 163 | ||
| 164 | Bundle payInfo = new Bundle(); | 164 | Bundle payInfo = new Bundle(); | 
| 165 | payInfo.putString("nick", "thi"); | 165 | payInfo.putString("nick", "thi"); | 
| 166 | payInfo.putString("product", "元宝"); | 166 | payInfo.putString("product", "元宝"); | 
| 167 | payInfo.putFloat("amount", 40.0f); | 167 | payInfo.putFloat("amount", 40.0f); | 
| 168 | payInfo.putString("extraInfo", "This is demo!"); | 168 | payInfo.putString("extraInfo", "This is demo!"); | 
| 169 | payInfo.putString("serverId", "B4003"); | 169 | payInfo.putString("serverId", "B4003"); | 
| 170 | payInfo.putString("roleId", "10010"); | 170 | payInfo.putString("roleId", "10010"); | 
| 171 | payInfo.putString("sessionKey","sessionkey"); | 171 | payInfo.putString("sessionKey","sessionkey"); | 
| 172 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); | 172 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); | 
| 173 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey | 173 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey | 
| 174 | 174 | ||
| 175 | 175 | ||
| 176 | 2)IAP支付 | 176 | 2)IAP支付 | 
| 177 | 177 | ||
| 178 | Bundle payInfo = new Bundle(); | 178 | Bundle payInfo = new Bundle(); | 
| 179 | payInfo.putString("product", "gp_skuId"); | 179 | payInfo.putString("product", "gp_skuId"); | 
| 180 | payInfo.putFloat("amount", 0.1f); | 180 | payInfo.putFloat("amount", 0.1f); | 
| 181 | payInfo.putString("extraInfo", "This is demo!"); | 181 | payInfo.putString("extraInfo", "This is demo!"); | 
| 182 | payInfo.putString("serverId", "100"); | 182 | payInfo.putString("serverId", "100"); | 
| 183 | payInfo.putString("roleId","100123"); | 183 | payInfo.putString("roleId","100123"); | 
| 184 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); | 184 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); | 
| 185 | 185 | ||
| 186 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 | 186 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 | 
| 187 | 187 | ||
| 188 | @Override | 188 | @Override | 
| 189 | public void onPurchaseCompleted(PurchaseResult result) { | 189 | public void onPurchaseCompleted(PurchaseResult result) { | 
| 190 | Log.i(TAG,"purchase completed"); | 190 | Log.i(TAG,"purchase completed"); | 
| 191 | } | 191 | } | 
| 192 | 192 | ||
| 193 | @Override | 193 | @Override | 
| 194 | public void onPurchaseError(int code, String msg) { | 194 | public void onPurchaseError(int code, String msg) { | 
| 195 | Log.i(TAG,"purchase error"); | 195 | Log.i(TAG,"purchase error"); | 
| 196 | } | 196 | } | 
| 197 | 197 | ||
| 198 | @Override | 198 | @Override | 
| 199 | public void onPurchaseCanceled() { | 199 | public void onPurchaseCanceled() { | 
| 200 | Log.i(TAG,"purchase canceled"); | 200 | Log.i(TAG,"purchase canceled"); | 
| 201 | } | 201 | } | 
| 202 | 202 | ||
| 203 | #### 4.注销登录 | 203 | #### 4.注销登录 | 
| 204 | 204 | ||
| 205 | GumpSDK.logout(Activity); | 205 | GumpSDK.logout(Activity); | 
| 206 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 | 206 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 | 
| 207 | #### 5.运营开关接口,若需要接入,会有我方运营人员提出需求,否则不需要接入(若对此接口不知所云,即可认为不需要接入,请自行忽略) | 207 | #### 5.运营开关接口,若需要接入,会有我方运营人员提出需求,否则不需要接入(若对此接口不知所云,即可认为不需要接入,请自行忽略) | 
| 208 | 208 | ||
| 209 | GumpSDK.checkRisk(this, new ResultCallback() { | 209 | GumpSDK.checkRisk(this, new ResultCallback() { | 
| 210 | @Override | 210 | @Override | 
| 211 | public void onResult(boolean result) { | 211 | public void onResult(boolean result) { | 
| 212 | Log.i(TAG,result?"There is some risks":"Nothing is risk"); | 212 | Log.i(TAG,result?"There is some risks":"Nothing is risk"); | 
| 213 | } | 213 | } | 
| 214 | }); | 214 | }); | 
| 215 | 215 | ||
| 216 | ## 第二章 常量字段与代码 | 216 | ## 第二章 常量字段与代码 | 
| 217 | ### 1.第三方登录平台(third_plat) | 217 | ### 1.第三方登录平台(third_plat) | 
| 218 | | 常量字段 | 说明 | | 218 | | 常量字段 | 说明 | | 
| 219 | |--------------------------------|--------------| | 219 | |--------------------------------|--------------| | 
| 220 | |SDKSettings.THIRD_SUPPORT_FB |Facebook登录 | | 220 | |SDKSettings.THIRD_SUPPORT_FB | Facebook登录 | | 
| 221 | |SDKSettings.THIRD_SUPPORT_GOOGLE|Google登录 | | 221 | |SDKSettings.THIRD_SUPPORT_GOOGLE| Google登录 | | 
| 222 | |SDKSettings.THIRD_SUPPORT_LINE |Line登录 | | 222 | |SDKSettings.THIRD_SUPPORT_LINE | Line登录 | | 
| 223 | |SDKSettings.THIRD_SUPPORT_VK |VK登录 | | 223 | |SDKSettings.THIRD_SUPPORT_VK | VK登录 | | 
| 224 | |SDKSettings.THIRD_SUPPORT_WECHAT|微信登录 | | 224 | |SDKSettings.THIRD_SUPPORT_WECHAT| 微信登录 | | 
| 225 | ### 2.登录账户类型 | 225 | ### 2.登录账户类型 | 
| 226 | | 常量字段 | 说明 | | 226 | | 常量字段 | 说明 | | 
| 227 | |-------------------------------------|-------------| | 227 | |-------------------------------------|--------------| | 
| 228 | |GumpPreference.ACCOUNT_TYPE_FB |Facebook用户 | | 228 | |GumpPreference.ACCOUNT_TYPE_FB | Facebook用户 | | 
| 229 | |GumpPreference.ACCOUNT_TYPE_REG |Gump注册用户 | | 229 | |GumpPreference.ACCOUNT_TYPE_REG | Gump注册用户 | | 
| 230 | |GumpPreference.ACCOUNT_TYPE_QUICK_REG|快速注册用户 | | 230 | |GumpPreference.ACCOUNT_TYPE_QUICK_REG| 快速注册用户 | | 
| 231 | |GumpPreference.ACCOUNT_TYPE_GOOGLE |Google用户 | | 231 | |GumpPreference.ACCOUNT_TYPE_GOOGLE | Google用户 | | 
| 232 | |GumpPreference.ACCOUNT_TYPE_LINE |Line用户 | | 232 | |GumpPreference.ACCOUNT_TYPE_LINE | Line用户 | | 
| 233 | |GumpPreference.ACCOUNT_TYPE_VK |VK用户 | | 233 | |GumpPreference.ACCOUNT_TYPE_VK | VK用户 | | 
| 234 | |GumpPreference.ACCOUNT_TYPE_WECHAT |微信用户 | | 234 | |GumpPreference.ACCOUNT_TYPE_WECHAT | 微信用户 | | 
| 235 | 235 | ||
| 236 | ## 第三章 常见问题 | 236 | ## 第三章 常见问题 | 
| 237 | ### 问题1: 如何避免混淆对SDK的影响? | 237 | ### 问题1: 如何避免混淆对SDK的影响? | 
| 238 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java | 238 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java | 
| 239 | 类,导致SDK无法正常工作,解决方法如下: | 239 | 类,导致SDK无法正常工作,解决方法如下: | 
| 240 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 | 240 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 | 
| 241 | 241 | ||
| 242 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable | 242 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable | 
| 243 | -keep public class * extends android.app.Service | 243 | -keep public class * extends android.app.Service | 
| 244 | -keep public class com.google.vending.licensing.ILicensingService | 244 | -keep public class com.google.vending.licensing.ILicensingService | 
| 245 | -keep public class com.android.vending.licensing.ILicensingService | 245 | -keep public class com.android.vending.licensing.ILicensingService | 
| 246 | -keep class com.gumptech.sdk.view.* {*;} | 246 | -keep class com.gumptech.sdk.view.* {*;} | 
| 247 | -keep class com.gumptech.sdk.web.* {*;} | 247 | -keep class com.gumptech.sdk.web.* {*;} | 
| 248 | -keep class com.gumptech.sdk.bridge.impl.*{*;} | 248 | -keep class com.gumptech.sdk.bridge.impl.*{*;} | 
| 249 | 249 | ||
| 250 | 250 | ||
| 251 | 使得混淆的时候不会影响SDK的命名空间。 | 251 | 使得混淆的时候不会影响SDK的命名空间。 |