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