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