Commit d4c3b9dce6cfcf46994c16c0c2987d87f323f606
1 parent
1a7b481630
Exists in
master
v4.7.6
Showing 3 changed files with 20 additions and 6 deletions Inline Diff
GameSDKDemo/build.gradle
1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
2 | 2 | ||
3 | /*The config for internal testing,you could ignore it | 3 | /*The config for internal testing,you could ignore it |
4 | * gump内部测试使用,你可以自行配置,或者直接删除这部分内容 | 4 | * gump内部测试使用,你可以自行配置,或者直接删除这部分内容 |
5 | * --start-- | 5 | * --start-- |
6 | */ | 6 | */ |
7 | def keystorePSW = '' | 7 | def keystorePSW = '' |
8 | def keystoreAlias = '' | 8 | def keystoreAlias = '' |
9 | def keystoreAliasPSW = '' | 9 | def keystoreAliasPSW = '' |
10 | // default keystore file, PLZ config file path in local.properties | 10 | // default keystore file, PLZ config file path in local.properties |
11 | def keyfile = file('s.keystore.temp') | 11 | def keyfile = file('s.keystore.temp') |
12 | 12 | ||
13 | Properties properties = new Properties() | 13 | Properties properties = new Properties() |
14 | // local.properties file in the root director | 14 | // local.properties file in the root director |
15 | properties.load(project.file('local.properties').newDataInputStream()) | 15 | properties.load(project.file('local.properties').newDataInputStream()) |
16 | def keystoreFilepath = properties.getProperty("keystore.path") | 16 | def keystoreFilepath = properties.getProperty("keystore.path") |
17 | 17 | ||
18 | if (keystoreFilepath) { | 18 | if (keystoreFilepath) { |
19 | keystorePSW = properties.getProperty("keystore.password") | 19 | keystorePSW = properties.getProperty("keystore.password") |
20 | keystoreAlias = properties.getProperty("keystore.alias") | 20 | keystoreAlias = properties.getProperty("keystore.alias") |
21 | keystoreAliasPSW = properties.getProperty("keystore.key_passwd") | 21 | keystoreAliasPSW = properties.getProperty("keystore.key_passwd") |
22 | keyfile = file(keystoreFilepath) | 22 | keyfile = file(keystoreFilepath) |
23 | } | 23 | } |
24 | /* | 24 | /* |
25 | * The config for internal testing,you could ignore it | 25 | * The config for internal testing,you could ignore it |
26 | * gump内部测试使用,你可以自行配置,或者直接删除这部分内容 | 26 | * gump内部测试使用,你可以自行配置,或者直接删除这部分内容 |
27 | * --end-- | 27 | * --end-- |
28 | */ | 28 | */ |
29 | 29 | ||
30 | repositories { | 30 | repositories { |
31 | maven { | 31 | maven { |
32 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" | 32 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" |
33 | } | 33 | } |
34 | jcenter() | 34 | jcenter() |
35 | google() | 35 | google() |
36 | } | 36 | } |
37 | 37 | ||
38 | android { | 38 | android { |
39 | compileSdkVersion 27 | 39 | compileSdkVersion 27 |
40 | buildToolsVersion '28.0.3' | 40 | buildToolsVersion '28.0.3' |
41 | 41 | ||
42 | signingConfigs { | 42 | signingConfigs { |
43 | release { | 43 | release { |
44 | storeFile keyfile | 44 | storeFile keyfile |
45 | storePassword keystorePSW | 45 | storePassword keystorePSW |
46 | keyPassword keystoreAliasPSW | 46 | keyPassword keystoreAliasPSW |
47 | keyAlias keystoreAlias | 47 | keyAlias keystoreAlias |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | defaultConfig { | 51 | defaultConfig { |
52 | minSdkVersion 14 | 52 | minSdkVersion 14 |
53 | targetSdkVersion 27 | 53 | targetSdkVersion 27 |
54 | applicationId "mx.she.rd4" | 54 | applicationId "mx.she.rd4" |
55 | versionCode 6 | 55 | versionCode 6 |
56 | versionName "1.4" | 56 | versionName "1.4" |
57 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | 57 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
58 | signingConfig signingConfigs.release | 58 | signingConfig signingConfigs.release |
59 | } | 59 | } |
60 | buildTypes { | 60 | buildTypes { |
61 | release { | 61 | release { |
62 | minifyEnabled false | 62 | minifyEnabled false |
63 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 63 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
64 | zipAlignEnabled true | 64 | zipAlignEnabled true |
65 | } | 65 | } |
66 | debug { | 66 | debug { |
67 | signingConfig signingConfigs.release | 67 | signingConfig signingConfigs.release |
68 | } | 68 | } |
69 | } | 69 | } |
70 | lintOptions { | 70 | lintOptions { |
71 | abortOnError false | 71 | abortOnError false |
72 | } | 72 | } |
73 | compileOptions { | 73 | compileOptions { |
74 | sourceCompatibility JavaVersion.VERSION_1_7 | 74 | sourceCompatibility JavaVersion.VERSION_1_7 |
75 | targetCompatibility JavaVersion.VERSION_1_7 | 75 | targetCompatibility JavaVersion.VERSION_1_7 |
76 | } | 76 | } |
77 | applicationVariants.all { | 77 | applicationVariants.all { |
78 | variant -> | 78 | variant -> |
79 | variant.outputs.all { | 79 | variant.outputs.all { |
80 | outputFileName = "GameSDKDemo-" + variant.name + defaultConfig.versionName + ".apk" | 80 | outputFileName = "GameSDKDemo-" + variant.name + defaultConfig.versionName + ".apk" |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | } | 84 | } |
85 | 85 | ||
86 | dependencies { | 86 | dependencies { |
87 | implementation fileTree(include: ['*.jar'], dir: 'libs') | 87 | implementation fileTree(include: ['*.jar'], dir: 'libs') |
88 | implementation 'com.android.support:support-v4:27.1.1' | 88 | implementation 'com.android.support:support-v4:27.1.1' |
89 | testImplementation 'junit:junit:4.12' | 89 | testImplementation 'junit:junit:4.12' |
90 | implementation 'com.android.support:appcompat-v7:27.1.1' | 90 | implementation 'com.android.support:appcompat-v7:27.1.1' |
91 | implementation 'com.android.support:design:27.1.1' | 91 | implementation 'com.android.support:design:27.1.1' |
92 | // implementation project(':GameSDK') | 92 | // implementation project(':GameSDK') |
93 | // implementation project(':IAP5Helper') | 93 | // implementation project(':IAP5Helper') |
94 | implementation 'com.gumptech.sdk:GameSDK:4.7.5_orange' | 94 | implementation 'com.gumptech.sdk:GameSDK:4.7.6' |
95 | // implementation 'com.gumptech.sdk:SamsungIAP:5.1.1' | 95 | // implementation 'com.gumptech.sdk:SamsungIAP:5.1.1' |
96 | } | 96 | } |
97 | 97 |
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-permission android:name="android.permission.INTERNET"/> | 5 | <uses-permission android:name="android.permission.INTERNET"/> |
6 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | 6 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> |
7 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | 7 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> |
8 | <!-- Danger Level permission--> | 8 | <!-- Danger Level permission--> |
9 | 9 | ||
10 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 10 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
11 | <uses-permission android:name="com.android.vending.BILLING"/> | 11 | <uses-permission android:name="com.android.vending.BILLING"/> |
12 | <!--samgung iap need this permission--> | 12 | <!--samgung iap need this permission--> |
13 | <uses-permission android:name="com.samsung.android.iap.permission.BILLING"/> | 13 | <uses-permission android:name="com.samsung.android.iap.permission.BILLING"/> |
14 | 14 | ||
15 | <application | 15 | <application |
16 | android:allowBackup="true" | 16 | android:allowBackup="true" |
17 | android:icon="@drawable/ic_launcher" | 17 | android:icon="@drawable/ic_launcher" |
18 | android:label="@string/app_name"> | 18 | android:label="@string/app_name"> |
19 | <activity | 19 | <activity |
20 | android:name="com.gumptech.sdk.demo.MainActivity" | 20 | android:name="com.gumptech.sdk.demo.MainActivity" |
21 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 21 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
22 | android:label="@string/app_name" | 22 | android:label="@string/app_name" |
23 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" | 23 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" |
24 | android:screenOrientation="portrait"> | 24 | android:screenOrientation="portrait"> |
25 | <intent-filter> | 25 | <intent-filter> |
26 | <action android:name="android.intent.action.MAIN"/> | 26 | <action android:name="android.intent.action.MAIN"/> |
27 | 27 | ||
28 | <category android:name="android.intent.category.LAUNCHER"/> | 28 | <category android:name="android.intent.category.LAUNCHER"/> |
29 | </intent-filter> | 29 | </intent-filter> |
30 | </activity> | 30 | </activity> |
31 | 31 | <activity | |
32 | android:name="com.gumptech.sdk.ContainerActivity" | ||
33 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
34 | android:launchMode="singleTask" | ||
35 | android:theme="@style/Theme.Orange" | ||
36 | android:screenOrientation="behind" | ||
37 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> | ||
38 | </activity> | ||
32 | <activity | 39 | <activity |
33 | android:name="com.gumptech.sdk.PaymentActivity" | 40 | android:name="com.gumptech.sdk.PaymentActivity" |
34 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 41 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
35 | android:launchMode="singleTask" | 42 | android:launchMode="singleTask" |
36 | android:screenOrientation="behind" | 43 | android:screenOrientation="behind" |
37 | android:theme="@style/Theme.Translucent"> | 44 | android:theme="@style/Theme.Translucent"> |
38 | <intent-filter> | 45 | <intent-filter> |
39 | <category android:name="android.intent.category.DEFAULT"/> | 46 | <category android:name="android.intent.category.DEFAULT"/> |
40 | 47 | ||
41 | <action android:name="android.intent.action.VIEW"/> | 48 | <action android:name="android.intent.action.VIEW"/> |
42 | 49 | ||
43 | <category android:name="android.intent.category.BROWSABLE"/> | 50 | <category android:name="android.intent.category.BROWSABLE"/> |
44 | 51 | ||
45 | <data | 52 | <data |
46 | android:host="com.gump.sdk" | 53 | android:host="com.gump.sdk" |
47 | android:scheme="gump100"/> | 54 | android:scheme="gump100"/> |
48 | </intent-filter> | 55 | </intent-filter> |
49 | </activity> | 56 | </activity> |
50 | 57 | ||
51 | </application> | 58 | </application> |
52 | 59 | ||
53 | 60 | ||
54 | </manifest> | 61 | </manifest> |
55 | 62 |
README.md
1 | # Gump SDK 4 for Android接入文档 | 1 | # Gump SDK 4 for Android接入文档 |
2 | 2 | ||
3 | 3 | ||
4 | V4.7.5_orange | 4 | V4.7.6 |
5 | 2019年07月12日 | 5 | 2019年07月25日 |
6 | 6 | ||
7 | 7 | ||
8 | ## 版本概述 | 8 | ## 版本概述 |
9 | 9 | ||
10 | 此版本为使用AndroidStudio开发的版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. | 10 | 此版本为使用AndroidStudio开发的版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. |
11 | 11 | ||
12 | 此SDK适用android4.0以上系统. | 12 | 此SDK适用android4.0以上系统. |
13 | 13 | ||
14 | ## 第一章 接入指南 | 14 | ## 第一章 接入指南 |
15 | ### 1.依赖导入 | 15 | ### 1.依赖导入 |
16 | 配置gradle,以下为必须项 | 16 | 配置gradle,以下为必须项 |
17 | 17 | ||
18 | repositories{ | 18 | repositories{ |
19 | maven{ | 19 | maven{ |
20 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" | 20 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" |
21 | } | 21 | } |
22 | } | 22 | } |
23 | dependencies { | 23 | dependencies { |
24 | implementation 'com.gumptech.sdk:GameSDK:4.7.5_orange' | 24 | implementation 'com.gumptech.sdk:GameSDK:4.7.6' |
25 | 25 | ||
26 | } | 26 | } |
27 | 27 | ||
28 | 28 | ||
29 | ### 2.修改AndroidManifest.xml文件 | 29 | ### 2.修改AndroidManifest.xml文件 |
30 | 首先添加必要的权限,如下所示: | 30 | 首先添加必要的权限,如下所示: |
31 | 31 | ||
32 | <uses-permission android:name="android.permission.INTERNET" /> | 32 | <uses-permission android:name="android.permission.INTERNET" /> |
33 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 33 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
34 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | 34 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> |
35 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 35 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
36 | <uses-permission android:name="com.android.vending.BILLING" /> | 36 | <uses-permission android:name="com.android.vending.BILLING" /> |
37 | 37 | ||
38 | 其次注册相应的Activity,具体如下: | 38 | 其次注册相应的Activity,具体如下: |
39 | 39 | ||
40 | 40 | <activity | |
41 | android:name="com.gumptech.sdk.ContainerActivity" | ||
42 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
43 | android:launchMode="singleTask" | ||
44 | android:theme="@style/Theme.Origin" //登录界面的主题,可选项:Theme.Origin\Theme.Orange\Theme.Blue | ||
45 | android:screenOrientation="behind" | ||
46 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> | ||
47 | </activity> | ||
41 | <activity | 48 | <activity |
42 | android:name="com.gumptech.sdk.PaymentActivity" | 49 | android:name="com.gumptech.sdk.PaymentActivity" |
43 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 50 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
44 | android:launchMode="singleTask" | 51 | android:launchMode="singleTask" |
45 | android:screenOrientation="behind" | 52 | android:screenOrientation="behind" |
46 | android:theme="@style/Theme.Translucent" > | 53 | android:theme="@style/Theme.Translucent" > |
47 | <intent-filter> | 54 | <intent-filter> |
48 | <category android:name="android.intent.category.DEFAULT" /> | 55 | <category android:name="android.intent.category.DEFAULT" /> |
49 | <action android:name="android.intent.action.VIEW" /> | 56 | <action android:name="android.intent.action.VIEW" /> |
50 | <category android:name="android.intent.category.BROWSABLE" /> | 57 | <category android:name="android.intent.category.BROWSABLE" /> |
51 | <data | 58 | <data |
52 | android:host="com.gump.sdk" | 59 | android:host="com.gump.sdk" |
53 | android:scheme="gump+游戏的appId" /> | 60 | android:scheme="gump+游戏的appId" /> |
54 | </intent-filter> | 61 | </intent-filter> |
55 | </activity> | 62 | </activity> |
56 | 63 | ||
57 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 | 64 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 |
58 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 | 65 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 |
59 | 66 | ||
60 | *是否打印debug日志 | 67 | *是否打印debug日志 |
61 | 68 | ||
62 | GumpSDK.getSettings().enableDebugLogging(true); | 69 | GumpSDK.getSettings().enableDebugLogging(true); |
63 | 70 | ||
64 | *设置需要启用的第三方登录,参数可选类型见第二章:[第三方登录平台](http://repository.gumptech.com:81/document/gamesdk4-android/blob/master/IntegrationGuide.md#1-third_plat) 字段说明 | 71 | *设置需要启用的第三方登录,参数可选类型见第二章:[第三方登录平台](http://repository.gumptech.com:81/document/gamesdk4-android/blob/master/IntegrationGuide.md#1-third_plat) 字段说明 |
65 | 72 | ||
66 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_*); | 73 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_*); |
67 | 74 | ||
68 | *若要使用V4版支付请设置 | 75 | *若要使用V4版支付请设置 |
69 | 76 | ||
70 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | 77 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); |
71 | 78 | ||
72 | #### 1.调用GumpSDK前需要执行初始化。 | 79 | #### 1.调用GumpSDK前需要执行初始化。 |
73 | 80 | ||
74 | 若不需要分渠道 | 81 | 若不需要分渠道 |
75 | 82 | ||
76 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); | 83 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); |
77 | 如果需要定义渠道,必须使用如下方法 | 84 | 如果需要定义渠道,必须使用如下方法 |
78 | 85 | ||
79 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); | 86 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); |
80 | 87 | ||
81 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 | 88 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 |
82 | 89 | ||
83 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | 90 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 |
84 | 91 | ||
85 | GumpSDK.start(Activity); | 92 | GumpSDK.start(Activity); |
86 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: | 93 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: |
87 | 94 | ||
88 | GumpSDK.setUserStateListener(new LoginStateListener() { | 95 | GumpSDK.setUserStateListener(new LoginStateListener() { |
89 | @Override | 96 | @Override |
90 | public void onLoginSuccess(GumpUser gumpUser) { | 97 | public void onLoginSuccess(GumpUser gumpUser) { |
91 | //登录成功,用户信息包含在GumpUser对象里 | 98 | //登录成功,用户信息包含在GumpUser对象里 |
92 | } | 99 | } |
93 | 100 | ||
94 | @Override | 101 | @Override |
95 | public void onLoginFailed(int code, String msg) { | 102 | public void onLoginFailed(int code, String msg) { |
96 | //登录出错,根据错误码和信息判断错误类型 | 103 | //登录出错,根据错误码和信息判断错误类型 |
97 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | 104 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); |
98 | } | 105 | } |
99 | 106 | ||
100 | @Override | 107 | @Override |
101 | public void onLoginCanceled() { | 108 | public void onLoginCanceled() { |
102 | //用户取消登录 | 109 | //用户取消登录 |
103 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 110 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
104 | } | 111 | } |
105 | 112 | ||
106 | @Override | 113 | @Override |
107 | public void onLogout() { | 114 | public void onLogout() { |
108 | //用户登出 | 115 | //用户登出 |
109 | 116 | ||
110 | } | 117 | } |
111 | @Override | 118 | @Override |
112 | public void onPermissionDenied(String[] deniedPermissions) { | 119 | public void onPermissionDenied(String[] deniedPermissions) { |
113 | //用户未授予权限,参数为没有获取的权限 | 120 | //用户未授予权限,参数为没有获取的权限 |
114 | } | 121 | } |
115 | }); | 122 | }); |
116 | 123 | ||
117 | 如上成功登录后收到的GumpUser对象包含以下信息 | 124 | 如上成功登录后收到的GumpUser对象包含以下信息 |
118 | 125 | ||
119 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! | 126 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! |
120 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 | 127 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 |
121 | gumpUser.getSessionKey();//登录的sessionKey对象,获取sessionKey字符串请使用此对象的getToken()方法 | 128 | gumpUser.getSessionKey();//登录的sessionKey对象,获取sessionKey字符串请使用此对象的getToken()方法 |
122 | 129 | ||
123 | #### 3.支付功能 | 130 | #### 3.支付功能 |
124 | 调用支付前需先获取支付状态,根据状态调用支付方法 | 131 | 调用支付前需先获取支付状态,根据状态调用支付方法 |
125 | 132 | ||
126 | GumpSDK.shouldUseCoPay(Activity, serverId, roleId, new ResultCallback() { | 133 | GumpSDK.shouldUseCoPay(Activity, serverId, roleId, new ResultCallback() { |
127 | @Override | 134 | @Override |
128 | public void onResult(boolean result) { | 135 | public void onResult(boolean result) { |
129 | if(result){ | 136 | if(result){ |
130 | //调用GumpSDK.iap | 137 | //调用GumpSDK.iap |
131 | }else{ | 138 | }else{ |
132 | //调用GumpSDK.pay | 139 | //调用GumpSDK.pay |
133 | } | 140 | } |
134 | } | 141 | } |
135 | }); | 142 | }); |
136 | 143 | ||
137 | 1)调用GumpSDK.pay | 144 | 1)调用GumpSDK.pay |
138 | 145 | ||
139 | Bundle payInfo = new Bundle(); | 146 | Bundle payInfo = new Bundle(); |
140 | payInfo.putString("product", "元宝"); | 147 | payInfo.putString("product", "元宝"); |
141 | payInfo.putFloat("amount", 40.0f); | 148 | payInfo.putFloat("amount", 40.0f); |
142 | payInfo.putString("extraInfo", "This is demo!"); | 149 | payInfo.putString("extraInfo", "This is demo!"); |
143 | payInfo.putString("serverId", "B4003"); | 150 | payInfo.putString("serverId", "B4003"); |
144 | payInfo.putString("roleId", "10010"); | 151 | payInfo.putString("roleId", "10010"); |
145 | payInfo.putString("currency","currency"); | 152 | payInfo.putString("currency","currency"); |
146 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); | 153 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); |
147 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,所有字段必须全部包含 | 154 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,所有字段必须全部包含 |
148 | 155 | ||
149 | 156 | ||
150 | 2)IAP支付 | 157 | 2)IAP支付 |
151 | 158 | ||
152 | Bundle payInfo = new Bundle(); | 159 | Bundle payInfo = new Bundle(); |
153 | payInfo.putString("product", "gp_skuId"); | 160 | payInfo.putString("product", "gp_skuId"); |
154 | payInfo.putFloat("amount", 0.1f); | 161 | payInfo.putFloat("amount", 0.1f); |
155 | payInfo.putString("extraInfo", "This is demo!"); | 162 | payInfo.putString("extraInfo", "This is demo!"); |
156 | payInfo.putString("serverId", "100"); | 163 | payInfo.putString("serverId", "100"); |
157 | payInfo.putString("roleId","100123"); | 164 | payInfo.putString("roleId","100123"); |
158 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); | 165 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); |
159 | 166 | ||
160 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 | 167 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 |
161 | 168 | ||
162 | @Override | 169 | @Override |
163 | public void onPurchaseCompleted(PurchaseResult result) { | 170 | public void onPurchaseCompleted(PurchaseResult result) { |
164 | Log.i(TAG,"purchase completed"); | 171 | Log.i(TAG,"purchase completed"); |
165 | } | 172 | } |
166 | 173 | ||
167 | @Override | 174 | @Override |
168 | public void onPurchaseError(int code, String msg) { | 175 | public void onPurchaseError(int code, String msg) { |
169 | Log.i(TAG,"purchase error"); | 176 | Log.i(TAG,"purchase error"); |
170 | } | 177 | } |
171 | 178 | ||
172 | @Override | 179 | @Override |
173 | public void onPurchaseCanceled() { | 180 | public void onPurchaseCanceled() { |
174 | Log.i(TAG,"purchase canceled"); | 181 | Log.i(TAG,"purchase canceled"); |
175 | } | 182 | } |
176 | 183 | ||
177 | #### 4.注销登录 | 184 | #### 4.注销登录 |
178 | 185 | ||
179 | GumpSDK.logout(Activity); | 186 | GumpSDK.logout(Activity); |
180 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 | 187 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 |
181 | #### 5.运营开关接口,若需要接入,会有我方运营人员提出需求,否则不需要接入(若对此接口不知所云,即可认为不需要接入,请自行忽略) | 188 | #### 5.运营开关接口,若需要接入,会有我方运营人员提出需求,否则不需要接入(若对此接口不知所云,即可认为不需要接入,请自行忽略) |
182 | 189 | ||
183 | GumpSDK.checkRisk(this, new ResultCallback() { | 190 | GumpSDK.checkRisk(this, new ResultCallback() { |
184 | @Override | 191 | @Override |
185 | public void onResult(boolean result) { | 192 | public void onResult(boolean result) { |
186 | Log.i(TAG,result?"There is some risks":"Nothing is risk"); | 193 | Log.i(TAG,result?"There is some risks":"Nothing is risk"); |
187 | } | 194 | } |
188 | }); | 195 | }); |
189 | 196 | ||
190 | ## 第二章 常量字段与代码 | 197 | ## 第二章 常量字段与代码 |
191 | ### 1.第三方登录平台(third_plat) | 198 | ### 1.第三方登录平台(third_plat) |
192 | | 常量字段 | 说明 | | 199 | | 常量字段 | 说明 | |
193 | |--------------------------------|--------------| | 200 | |--------------------------------|--------------| |
194 | |SDKSettings.THIRD_SUPPORT_FB | Facebook登录 | | 201 | |SDKSettings.THIRD_SUPPORT_FB | Facebook登录 | |
195 | |SDKSettings.THIRD_SUPPORT_GOOGLE| Google登录 | | 202 | |SDKSettings.THIRD_SUPPORT_GOOGLE| Google登录 | |
196 | |SDKSettings.THIRD_SUPPORT_LINE | Line登录 | | 203 | |SDKSettings.THIRD_SUPPORT_LINE | Line登录 | |
197 | 204 | ||
198 | ### 2.登录账户类型 | 205 | ### 2.登录账户类型 |
199 | | 常量字段 | 说明 | | 206 | | 常量字段 | 说明 | |
200 | |-------------------------------------|--------------| | 207 | |-------------------------------------|--------------| |
201 | |GumpPreference.ACCOUNT_TYPE_FB | Facebook用户 | | 208 | |GumpPreference.ACCOUNT_TYPE_FB | Facebook用户 | |
202 | |GumpPreference.ACCOUNT_TYPE_REG | Gump注册用户 | | 209 | |GumpPreference.ACCOUNT_TYPE_REG | Gump注册用户 | |
203 | |GumpPreference.ACCOUNT_TYPE_QUICK_REG| 游客 | | 210 | |GumpPreference.ACCOUNT_TYPE_QUICK_REG| 游客 | |
204 | |GumpPreference.ACCOUNT_TYPE_GOOGLE | Google用户 | | 211 | |GumpPreference.ACCOUNT_TYPE_GOOGLE | Google用户 | |
205 | |GumpPreference.ACCOUNT_TYPE_LINE | Line用户 | | 212 | |GumpPreference.ACCOUNT_TYPE_LINE | Line用户 | |
206 | 213 | ||
207 | 214 | ||
208 | 215 | ||
209 | ## 第三章 常见问题 | 216 | ## 第三章 常见问题 |
210 | ### 问题1: 如何避免混淆对SDK的影响? | 217 | ### 问题1: 如何避免混淆对SDK的影响? |
211 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java | 218 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java |
212 | 类,导致SDK无法正常工作,解决方法如下: | 219 | 类,导致SDK无法正常工作,解决方法如下: |
213 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 | 220 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 |
214 | 221 | ||
215 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable | 222 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable |
216 | -keep public class * extends android.app.Service | 223 | -keep public class * extends android.app.Service |
217 | -keep public class com.google.vending.licensing.ILicensingService | 224 | -keep public class com.google.vending.licensing.ILicensingService |
218 | -keep public class com.android.vending.licensing.ILicensingService | 225 | -keep public class com.android.vending.licensing.ILicensingService |
219 | -keep class com.gumptech.sdk.view.* {*;} | 226 | -keep class com.gumptech.sdk.view.* {*;} |
220 | -keep class com.gumptech.sdk.web.* {*;} | 227 | -keep class com.gumptech.sdk.web.* {*;} |
221 | -keep class com.gumptech.sdk.bridge.impl.*{*;} | 228 | -keep class com.gumptech.sdk.bridge.impl.*{*;} |
222 | 229 | ||
223 | 230 | ||
224 | 使得混淆的时候不会影响SDK的命名空间。 | 231 | 使得混淆的时候不会影响SDK的命名空间。 |