SDK Integration
<p>[TOC]</p>
<h2>Version</h2>
<table>
<thead>
<tr>
<th>Version number</th>
<th>Time</th>
<th>Modify content</th>
<th>Responsible person</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<tr>
<td>V1.0</td>
<td>2018/12/26</td>
<td>First written</td>
<td>fluty.xie</td>
</tr>
<tr>
<td>V1.1</td>
<td>2019/01/03</td>
<td>Write Again</td>
<td>laimo.li</td>
<td>No Listening Payment Success Notification Callback</td>
</tr>
<tr>
<td>V1.2</td>
<td>2019/01/08</td>
<td>Improve user scenarios</td>
<td>caden.liu</td>
<td>none</td>
</tr>
<tr>
<td>V1.3</td>
<td>2019/01/21</td>
<td>Add sharing function</td>
<td>fluty.xie</td>
</tr>
<tr>
<td>V1.3.1</td>
<td>2019/04/04</td>
<td>Update the key used by the payment interface to pass the parameter</td>
<td>tony.lai</td>
<td>None</td>
</tr>
<tr>
<td>V1.3.2</td>
<td>2019/04/09</td>
<td>Add "4.5 UI version" account system access instructions</td>
<td>tony.lai</td>
<td>none</td>
</tr>
<tr>
<td>V1.4</td>
<td>2019/05/15</td>
<td>Microservice Payment Interface Parameter Changes</td>
<td>fluty.xie</td>
<td>None</td>
</tr>
<tr>
<td>V1.5</td>
<td>2019/05/23</td>
<td>Microservices without UI interface changes</td>
<td>wesley.zhong</td>
<td>none</td>
</tr>
<tr>
<td>V1.6</td>
<td>2019/05/31</td>
<td>Routing ID Classification Correction</td>
<td>nic.huang</td>
<td>None</td>
</tr>
<tr>
<td>V1.7</td>
<td>2019/07/26</td>
<td>Add Aurora one-click login, etc.</td>
<td>wesley.zhong</td>
</tr>
</tbody>
</table>
<h3>1 Overview</h3>
<ul>
<li>MSSDK (Micro Services SDK) is a new standardized SDK provided by the 2019 technology middle platform.</li>
<li>Support Android 4.1 and above, support Android Studio development tools.</li>
<li>This article mainly describes the Android MSSDK novice integration tutorial, please refer to the "MSSDK API document" for API call details.</li>
</ul>
<p><em>Remarks: The current version supports the user, payment and data statistics capabilities of the game distribution business in the basic minimum range of the Android public channel. </em></p>
<p><strong> Special attention: If the game developers are about to access is the type of online games (leisure games can be ignored), in order to login and pay security, the server access related interface is required. Specific access documents can be viewed <a href="https://www.showdoc.cc/mssdk?Page_id=26478972757260">MSSDK server documents</a></strong></p>
<h3>2 Preparation for the matter</h3>
<h4>2.1 Creating a micro service APP application</h4>
<ul>
<li>Log in to the [Micro Service Business Console] (<a href="http://biz.cloud.idreamsky.com">http://biz.cloud.idreamsky.com</a>) to create the application and place the downloaded configuration file msConfig.json in the assets\msld\config directory under the project directory.</li>
<li>
<p>As shown below:
<img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_01.png?raw=true" alt="image" /></p>
</li>
<li>If there is no micro service account, please contact the person in charge of the micro service.</li>
</ul>
<h4>2.2 Setting the game payment callback address</h4>
<ul>
<li>The game payment callback address is the URL used to receive the arrival notification. The MSSDK will send a synchronization request to the URL after the recharge is successful.</li>
<li>Configuration entry: [Micro Service Business Console] (<a href="http://biz.cloud.idreamsky.com">http://biz.cloud.idreamsky.com</a>), as shown below:</li>
<li><strong>Note</strong>: For casual games where the client issues goods, please fill in <strong><a href="http://ois-pay.uu.cc/order/sdk_callback">http://ois-pay.uu.cc/order/sdk_callback</a></strong></li>
<li><img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_02.png?raw=true" alt="image" /></li>
</ul>
<h4>2.3 Planning integration plan</h4>
<h5>2.3.1 Login page (required)</h5>
<ul>
<li>The user enters the game for the first time, loads the game resources, and enters the "game login page"</li>
<li>The user clicks "Account Login" on the "Game Login Page" to open the login panel, and clicks "Quick Access" to use the visitor login process.</li>
<li>Design reference:</li>
<li><img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_03.png?raw=true" alt="image" /></li>
</ul>
<h5>2.3.2 User Center (required)</h5>
<ul>
<li>The user successfully logs into the game and provides a "User Center" entry for the user to maintain the account personal information.</li>
<li>Design Reference 1: The main interface of the game provides an entrance</li>
<li><img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_04.png?raw=true" alt="image" /></li>
<li>Design Reference 2: Provide entry in the game settings</li>
<li><img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_05.png?raw=true" alt="image" /></li>
</ul>
<h3>3 SDK integration</h3>
<h4>3.1 Getting SDK and configuration files</h4>
<ul>
<li>Get the MSDK resource aar package. </li>
<li>Get the configuration file msConfig.json, [see 2.1] (#2.1 Create Micro Service APP Application)</li>
<li>If you have any questions, please contact the Technology Platform Division - SDK Development Platform Group.</li>
</ul>
<h4>3.2 Configuring the development environment</h4>
<ul>
<li>Use Android Studio development tools</li>
</ul>
<h5>3.2.1 Importing SDK resources to the project</h5>
<ul>
<li>Under Project Engineering, create a new module with the name MSSDK. And copy aar and msConfig.json to the corresponding directory as shown below</li>
</ul>
<p><img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_06.png?raw=true" alt="image" /></p>
<h5>3.2.2 Gradle configuration</h5>
<ul>
<li>Add the code in the MSSDK build.gradle configuration file as follows:</li>
</ul>
<pre><code class="language-Android">Android {
Repositories {
flatDir {
Dirs 'libs'
}
}
}
Dependencies {
Implementation fileTree(dir: 'libs', include: ['*.jar'])
Api fileTree(include: ['*.aar'], dir: 'libs')
}</code></pre>
<h4>3.3 Initializing the SDK</h4>
<ul>
<li>Call the initialization function in onCreate() of the game's main Activity</li>
<li>Call example:</li>
</ul>
<p><em>Note: The initialization parameters are read from the SDK configuration file. The parameter error will cause the initialization to fail. Only the initialization is successful, and the functions of the SDK can be used normally. </em></p>
<pre><code class="language-Android">MSLDSDK.getInstance().initSDK(this, new MSLDCallback() {
@Override
Void onSuccess(String msg, Object data) {
Show("Initial success");
}
@Override
Void onFail(int code, String msg, Object errorData) {
Show("initial failed");
}
});</code></pre>
<h4>3.4 APP Lifecycle Listening Call</h4>
<ul>
<li>Inform MSSDK of events that occurred during the life of the app.</li>
</ul>
<h5>3.4.1 Calling the Application Lifecycle Listening Interface</h5>
<ul>
<li>Call example:</li>
</ul>
<pre><code class="language-java">MSLDSDK.App.onCreate(this);
MSLDSDK.App.attachBaseContext(this, base);
MSLDSDK.App.onLowMemory(this);
MSLDSDK.App.onTrimMemory(this,level);
MSLDSDK.App.onConfigurationChanged(this,newConfig);</code></pre>
<h5>3.4.2 Call Activity Lifecycle Listening Interface</h5>
<ul>
<li>Call example:</li>
</ul>
<pre><code class="language-java">MSLDSDK.Act.onCreate(activtiy, savedInstanceState);
MSLDSDK.Act.onRestart(activtiy);
MSLDSDK.Act.onStart(activtiy);
MSLDSDK.Act.onResume(activtiy);
MSLDSDK.Act.onPause(activtiy);
MSLDSDK.Act.onStop(activtiy);
MSLDSDK.Act.onDestroy(activtiy);
MSLDSDK.Act.onSaveInstanceState(activtiy, outState);
MSLDSDK.Act.onNewIntent(intent);
MSLDSDK.Act.onActivityResult(activtiy, requestCode, resultCode, data);
MSLDSDK.Act.onRequestPermissionsResult(activtiy, requestCode, permissions, paramArrayOfInt);</code></pre>
<h3>4 Function integration</h3>
<ul>
<li>The MSSDK functions can be called only if the SDK is successfully initialized.</li>
<li>MSSDK provides user, payment and data statistics.</li>
</ul>
<h4>4.1 Access User</h4>
<ul>
<li>MSSDK user features provide login, user center and real-name authentication capabilities.</li>
</ul>
<h5>4.1.1 Login Panel</h5>
<ul>
<li>The login panel provides a login UI interface.</li>
<li>The current version supports one-click login, mobile phone number verification code, username and password, and visitor login.</li>
<li>
<p>If the one-click login display condition is met, the one-click login authorization page is displayed first, otherwise the normal login panel (mobile number login or account selection panel) is displayed.
<img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_07.png?raw=true" alt="image" /></p>
</li>
<li>Call example:</li>
</ul>
<pre><code class="language-java">MSLDSDK.action(this, AccountPath.ROUTE_ACCOUNT_LOGIN, new HashMap<>(), new
MSLDCallback<MSLDAccount>() {
@Override
Public void onSuccess(String msg, MSLDAccount data) {
}
@Override
Public void onFail(int code, String msg, Object errorData) {
}
});</code></pre>
<h5>4.1.2 Visitor Login</h5>
<ul>
<li>Create a guest account for the user and enter the gaming experience without any verification.</li>
<li>Call example:</li>
</ul>
<pre><code class="language-java">MSLDSDK.action(this, AccountPath.ROUTE_ACCOUNT_GUEST_LOGIN, new HashMap<>(), new
MSLDCallback<MSLDAccount>() {
@Override
Public void onSuccess(String msg, MSLDAccount data) {
}
@Override
Public void onFail(int code, String msg, Object errorData) {
}
});</code></pre>
<h5>4.1.3 Automatic login</h5>
<ul>
<li>User scene: The user logs in successfully without triggering the logout. When the game is started again, there is no need to verify and enter the game directly.</li>
<li>SDK logic: The game calls the MSSDK automatic login interface, and the MSSDK uses the last login information to automatically log in.</li>
<li>Call example:</li>
</ul>
<pre><code class="language-java">MSLDSDK.action(this, AccountPath.ROUTE_ACCOUNT_AUTO_LOGIN, new HashMap<>(), new
MSLDCallback<MSLDAccount>() {
@Override
Public void onSuccess(String msg, MSLDAccount data) {
}
@Override
Public void onFail(int code, String msg, Object errorData) {
}
});</code></pre>
<h5>4.1.4 Listening for login notification callbacks</h5>
<ul>
<li>The user may change the login status during the game, and the MSSDK informs the game by means of the notification class callback.</li>
<li>The game needs to listen to the "login notification callback" throughout the lifecycle to process the business logic of the game account in a timely manner.</li>
<li>The current version has initialization success, user login success, user logout, and switch account success event.</li>
</ul>
<pre><code class="language-java">MSLDSDK.registerNotifyListener(new MSLDNotifyListener() {
@Override
Public void notify(int code, String msg, Object data) {
Switch (code) {
Case NotifyCode.SWITCH_ACCOUNT:
// Switch account and log in successfully
MSLDAccount account = (MSLDAccount )data;
Break;
Case NotifyCode.INNER_CODE_INIT_SUCCESS:
// Initialization successful
Break;
Case NotifyCode.INNER_CODE_LOGIN_SUCCESS:
// Landed successfully
Break;
Case NotifyCode.LOGOUT:
// Sign out
Break;
Default:
// other
Break;
}
}
});</code></pre>
<h5>4.1.5 User Center</h5>
<ul>
<li>User Center is to supplement the information of the game account, including user information, mobile phone binding, password setting, real-name authentication, account switching, fast account and other functions.</li>
</ul>
<p><img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_08.png?raw=true" alt="image" /></p>
<ul>
<li>Call example:</li>
</ul>
<pre><code class="language-java">MSLDSDK.action(this, AccountPath.ROUTE_ACCOUNT_USER_CENTER, new
HashMap<String, Object>(), new MSLDCallback() {
@Override
Public void onSuccess(String msg, Object data) {
}
@Override
Public void onFail(int code, String msg, Object errorData) {
}
});</code></pre>
<h5>4.1.6 Real Name Certification (optional)</h5>
<ul>
<li>The user center panel has a real-name authentication entry, and a separate real-name authentication interface (including UI) supports direct calls to the game in other scenarios.</li>
<li>Call example:</li>
</ul>
<pre><code class="language-Android">MSLDSDK.action(this, AccountPath.ROUTE_ACCOUNT_AUTHENTICATION, null, new MSLDCallback() {
@Override
Public void onSuccess(String msg, @Nullable Object data) {
Show("real name authentication succeeded");
}
@Override
Public void onFail(int code, String msg, @Nullable Object errorData) {
Show("real name authentication failed" + msg);
}
});</code></pre>
<h5>4.1.7 Obtaining User Information (optional)</h5>
<ul>
<li>Get user information of the current user</li>
<li>Call example:</li>
</ul>
<pre><code class="language-java">MSLDAccount account = MSLDSDK.syncAction(this,AccountPath.ROUTE_ACCOUNT_LOGINED_USER_INFO,null);</code></pre>
<h5>4.1.8 Best Practices</h5>
<ul>
<li>Login interface calls best practices:
<img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_09.jpg?raw=true" alt="image" /></li>
</ul>
<h4>4.2 Access Payment</h4>
<ul>
<li>The MSSDK payment feature provides the ability to pay for panels and specified payment methods, on-demand.</li>
<li>Pre-conditions: Configure game product information on [Loke Developer Platform] (<a href="https://dev.idreamsky.com/">https://dev.idreamsky.com/</a>) and pass the product ID when calling the payment interface.</li>
<li>The payment function depends on the user function, and the payment related interface can be tuned only when the user logs in.</li>
<li><strong>Note</strong>: The game that the client issues the product must receive the payment success notification callback (see section 4.2.3 of this document) before the product can be issued.</li>
</ul>
<h5>4.2.1 Payment Panel</h5>
<ul>
<li>The user is logged in to use the payment panel feature.</li>
<li>
<p>The payment panel provides a payment checkout counter, and online control of payment methods can be contacted by frontline customer support personnel.</p>
<p><img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_10.png?raw=true" alt="image" /></p>
</li>
<li>Call example:</li>
</ul>
<pre><code class="language-Android">HashMap<String, Object> map = new HashMap<String, Object>();
// merchandise payment direct incoming price
Map.put(PaymentParam.PAY_PLAYER_ID, "300012345");
Map.put(PaymentParam.PAY_MCH_ORDER_NO, "123456");
Map.put(PaymentParam.PAY_PRODUCT_DES, "Platform Payment Description");
Map.put(PaymentParam.PAY_SUBJECT, "Platform Payment Order Title");
Map.put(PaymentParam.PAY_PRICE, "6");
Map.put(PaymentParam.PAY_ATTACH, "transparent information");
// Platform payment platform needs to configure prop files can be imported into multiple props
Map.put(PaymentParam.PAY_PLAYER_ID, "300012345");
Map.put(PaymentParam.PAY_MCH_ORDER_NO, "123456");
Map.put(PaymentParam.PAY_PRODUCT_DES, "Platform Payment Description");
Map.put(PaymentParam.PAY_SUBJECT, "Platform Payment Order Title");
Map.put(PaymentParam.PAY_ATTACH, "transparent information");
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(PaymentParam.PAY_PRODUCT_ID, "laimo_product");
jsonObject.addProperty(PaymentParam.PAY_QUANTITY, 1);
JsonArray jsonArray = new JsonArray();
jsonArray.add(jsonObject);
Map.put(PaymentParam.PAY_PRODUCT_LIST, jsonArray.toString());
MSLDSDK.action(this, PayPath.ROUTE_PAY_CHARGE, map, new
MSLDPayCallback() {
@Override
Public void onComplete() {
Show("Payment completed");
}
@Override
Public void onCancel() {
Show("payment cancellation");
}
@Override
Public void onFail(int code, String msg) {
Show(msg);
}
});</code></pre>
<ul>
<li><strong>Note</strong>: The client callback of the payment interface only represents the completion of the payment action. The game delivery is subject to the payment server notification. The casual game delivered by the client is subject to the <strong>payment success notification callback</strong> (detailed) See section 4.2.3 of this document)</li>
</ul>
<h5>4.2.2 Specifying payment method to pay</h5>
<ul>
<li>The user is logged in to use the specified payment method feature.</li>
<li>No UI interface, directly call the channel three-party payment interface, currently supports WeChat and Alipay.</li>
<li>Call example:</li>
</ul>
<pre><code class="language-Android">HashMap<String, Object> map = new HashMap<String, Object>();
// merchandise payment direct incoming price
Map.put(PaymentParam.PAY_PLAYER_ID, "300012345");
Map.put(PaymentParam.PAY_MCH_ORDER_NO, "123456");
Map.put(PaymentParam.PAY_PRODUCT_DES, "Platform Payment Description");
Map.put(PaymentParam.PAY_SUBJECT, "Platform Payment Order Title");
Map.put(PaymentParam.PAY_PRICE, "6");
Map.put(PaymentParam.PAY_ATTACH, "transparent information");
// Platform payment platform needs to configure prop files can be imported into multiple props
Map.put(PaymentParam.PAY_PLAYER_ID, "300012345");
Map.put(PaymentParam.PAY_MCH_ORDER_NO, "123456");
Map.put(PaymentParam.PAY_PRODUCT_DES, "Platform Payment Description");
Map.put(PaymentParam.PAY_SUBJECT, "Platform Payment Order Title");
Map.put(PaymentParam.PAY_ATTACH, "transparent information");
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(PaymentParam.PAY_PRODUCT_ID, "laimo_product");
jsonObject.addProperty(PaymentParam.PAY_QUANTITY, 1);
JsonArray jsonArray = new JsonArray();
jsonArray.add(jsonObject);
Map.put(PaymentParam.PAY_PRODUCT_LIST, jsonArray.toString());
// Payment ID, assigned by the music service console, WeChat payment: wxPay_H5 alipay: aliPay_H5
Map.put(PaymentParam.PAY_IDENTIFY, "aliPay_H5");
MSLDSDK.action(this, PayPath.ROUTE_PAY_BY_METHOD_ID, map, new
MSLDPayCallback() {
@Override
Public void onComplete() {
Show("Payment completed");
}
@Override
Public void onCancel() {
Show("payment cancellation");
}
@Override
Public void onFail(int code, String msg) {
Show(msg);
}
});</code></pre>
<ul>
<li><strong>Note</strong>: The client callback of the payment interface only represents the completion of the payment action. The game delivery is subject to the payment server notification. The casual game delivered by the client is subject to the <strong>payment success notification callback</strong> (detailed) See section 4.2.3 of this document)</li>
</ul>
<h5>4.2.3 Monitor payment success notification callback (client must issue goods)</h5>
<ul>
<li>Turn on order polling (best practice: execute after login successful callback)</li>
</ul>
<pre><code class="language-Android">MSLDSDK.action(activity, PaymentPath.ROUTE_START_ORDER_POLLIN, new
HashMap<String, Object>() {
{
Put("playerId", playerId);
}
}, null);</code></pre>
<ul>
<li>Stop order polling (best practice: execute when logging out of callback)</li>
</ul>
<pre><code class="language-Android">MSLDSDK.action(activity, PaymentPath.ROUTE_STOP_ORDER_POLLIN,
Null, null);</code></pre>
<ul>
<li>The user may have an abnormal situation during the payment process, and the client callback result of the payment interface is not accurate.</li>
<li>MSSDK will inform the game in the form of "Payment Success Notification Callback" with the server's trustworthy payment result.</li>
<li>The game needs to monitor the "Payment Success Notification Callback" throughout the life cycle, process the business logic of the product release in a timely manner, and report the order consumption result (see section 4.2.4 of this document for details).</li>
<li>Call example:</li>
</ul>
<pre><code class="language-Android">MSLDSDK.registerNotifyListener(new MSLDNotifyListener() {
@Override
Public void notify(int code, String msg, Object data) {
Switch (code) {
Case NotifyCode.PAY_SUCCESS:
// payment success notification
Break;
Default:
// other
Break;
}
}
});</code></pre>
<h5>4.2.4 Reporting the result of the order (the client must issue the product)</h5>
<ul>
<li>In order to ensure the security of the "Payment Success Notification Callback" and to avoid duplicate shipments, MSSDK requires the game to report the result of the order consumption as a record.</li>
<li>Call timing: Listen to the payment success notification callback (see section 4.2.3 of this document for details) and successfully distribute the product.</li>
<li>Call example:</li>
</ul>
<pre><code class="language-Android">HashMap<String, Object> params = new HashMap<>();
Params.put("orderId", "DD123456789");
MSLDSDK.action(this, PayPath.ROUTE_PAY_REPORT_COMSUMED, params, new MSLDCallback() {
@Override
Public void onSuccess(String s, @Nullable Object o) {
Log.i(TAG, "onSuccess: The result of the shipment has been notified successfully s = " + s);
}
@Override
Public void onFail(int i, String s, @Nullable Object o) {
Log.w(TAG, "onFail: The result of the shipment has been notified successfully i = " + i + "; s = " + s);
}
});</code></pre>
<h5>4.2.5 Best Practices</h5>
<ul>
<li>Payment interface call best practices:
<img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Android/guide-UI/guide_11.jpg?raw=true" alt="image" />
<h4>4.3 Access Sharing</h4></li>
<li>MSSDK sharing feature provides WeChat and QQ sharing capabilities.</li>
<li>The current version supports the following sharing scenarios:
<ol>
<li>Share pictures to WeChat session / WeChat session / QQ friends / Qzone</li>
<li>Share the link to WeChat session / WeChat session / QQ friends / Qzone</li>
<li>Share WeChat applet to WeChat session</li>
<li>Apply to open the WeChat applet</li>
</ol></li>
</ul>
<h5>4.3.1 QQ Sharing</h5>
<h6>4.3.1.1 Applying for QQ parameters</h6>
<ul>
<li>Create an app and get the QQ AppId in [QQ Connected Platform] (<a href="https://connect.qq.com/index.html">https://connect.qq.com/index.html</a>), contact the channel business colleagues.</li>
<li>Fill in the QQ AppId in the MSSDK configuration file msConfig. For details, please contact the Technology Platform Department - SDK Development Platform Group.</li>
</ul>
<h6>4.3.1.2 Configuring Androidmanifest.xml</h6>
<ul>
<li>Add permission component</li>
</ul>
<pre><code class="language-xml"><uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /></code></pre>
<ul>
<li>Add activity component</li>
</ul>
<p>Note: You need to change the app_Id to the application's QQ appId value, for example: <data android:scheme="tencent123456789" /></p>
<pre><code class="language-xml"><activity
Android:name="com.tencent.tauth.AuthActivity"
Android:launchMode="singleTask"
Android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Replace app_Id with the AppId applied by the game in the QQ background -->
<data android:scheme="tencentapp_Id" />
</intent-filter>
</activity>
<activity
Android:name="com.tencent.connect.common.AssistActivity"
Android:configChanges="orientation|keyboardHidden"
Android:screenOrientation="behind"
Android:theme="@android:style/Theme.Translucent.NoTitleBar" /></code></pre>
<h6>4.3.1.3 Calling QQ sharing function</h6>
<ul>
<li>Share pictures to QQ friends</li>
</ul>
<pre><code class="language-java">HashMap<String, Object> map = new HashMap<String, Object>();
Map.put("scene", ShareParam.SHARE_QQ_FRIENDS);
Map.put("image", "imagePath");
MSLDSDK.action(this, SharePath.ROUTE_SHARE_IMAGE, map, new MSLDCallback() {
@Override
Public void onSuccess(String msg, @Nullable Object data) {
Show("share success");
}
@Override
Public void onFail(int code, String msg, @Nullable Object errorData) {
Show("Share failed" + msg);
}
});</code></pre>
<ul>
<li>Share pictures to QZone</li>
</ul>
<pre><code class="language-java">HashMap<String, Object> map = new HashMap<String, Object>();
Map.put("scene", ShareParam.SHARE_QQ_QZONE);
Map.put("image", "imagePath");
MSLDSDK.action(this, SharePath.ROUTE_SHARE_IMAGE, map, new MSLDCallback() {
@Override
Public void onSuccess(String msg, @Nullable Object data) {
Show("share success");
}
@Override
Public void onFail(int code, String msg, @Nullable Object errorData) {
Show("Share failed" + msg);
}
});</code></pre>
<ul>
<li>Share links to QQ friends</li>
</ul>
<pre><code class="language-java">HashMap<String, Object> map = new HashMap<String, Object>();
Map.put("scene", ShareParam.SHARE_QQ_FRIENDS);
Map.put("thumbImage", WechatUtils.toHexString(getBytes(file));
Map.put("webpageUrl", "Link to share");
Map.put("title", "link title");
Map.put("description", "link description");
MSLDSDK.action(this, SharePath.ROUTE_SHARE_WEBPAGE, map, new MSLDCallback() {
@Override
Public void onSuccess(String msg, @Nullable Object data) {
Show("share success");
}
@Override
Public void onFail(int code, String msg, @Nullable Object errorData) {
Show("Share failed" + msg);
}
});</code></pre>
<ul>
<li>Share link to QZone
<pre><code class="language-java">
HashMap<String, Object> map = new HashMap<String, Object>();
Map.put("scene", ShareParam.SHARE_QQ_QZONE);
Map.put("thumbImage", WechatUtils.toHexString(getBytes(file));
Map.put("webpageUrl", "Link to share");
Map.put("title", "link title");
Map.put("description", "link description");
MSLDSDK.action(this, SharePath.ROUTE_SHARE_WEBPAGE, map, new MSLDCallback() {
@Override
Public void onSuccess(String msg, @Nullable Object data) {
Show("share success");
}</code></pre></li>
</ul>
<p> @Override
Public void onFail(int code, String msg, @Nullable Object errorData) {
Show("Share failed" + msg);
}
});</p>
<pre><code>
##### 4.3.2 WeChat Sharing
###### 4.3.2.1 Applying WeChat Parameters
- Create an app on WeChat Open Platform (https://open.weixin.qq.com/) and get the WeChat AppId, specifically contact the channel business colleagues.
- Fill in the WeChat AppId in the MSSDK configuration file msConfig.json. For details, please contact the Technology Platform Department - SDK Development Platform Group.
###### 4.3.2.2 Configuring WXEntryActivity
- First create a new wxapi directory in the application package name directory, then add the WXEntryActivity class in the wxapi directory, and inherit the class from WeixinShareAbstract.
- WXEntryActivity project configuration example (application package name is com.idreamsky.hawk):
- 
- WXEntryActivity class example:
```java
Package com.idreamsky.hawk.wxapi;
Import com.ms.plugin.wechat.WeixinShareAbstract;
/**
* WeChat callback Activity
*/
Public class WXEntryActivity extends WeixinShareAbstract {
}</code></pre>
<h6>4.3.2.3 Configuring Androidmanifest.xml</h6>
<ul>
<li>Add permission component</li>
</ul>
<pre><code class="language-xml"><uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/></code></pre>
<ul>
<li>Add activity component</li>
</ul>
<p>Note: Replace <strong>package name</strong> with the actual application package name</p>
<pre><code class="language-xml"> <activity
Android:name="package name.wxapi.WXEntryActivity"
Android:label="@string/app_name"
Android:theme="@android:style/Theme.Translucent.NoTitleBar"
Android:exported="true"
Android:taskAffinity="package name"
Android:launchMode="singleTask">
</activity></code></pre>
<h6>4.3.2.4 Calling WeChat Sharing</h6>
<ul>
<li>Share pictures to WeChat sessions</li>
</ul>
<pre><code class="language-java">HashMap<String, Object> map = new HashMap<String, Object>();
Map.put("scene", ShareParam.SHARE_WECHAT_SESSION);
Map.put("image", "imagePath");
MSLDSDK.action(this, SharePath.ROUTE_SHARE_IMAGE, map, new MSLDCallback() {
@Override
Public void onSuccess(String msg, @Nullable Object data) {
Show("share success");
}
@Override
Public void onFail(int code, String msg, @Nullable Object errorData) {
Show("Share failed" + msg);
}
});</code></pre>
<ul>
<li>Share pictures to circle of friends</li>
</ul>
<pre><code class="language-java">HashMap<String, Object> map = new HashMap<String, Object>();
Map.put("scene", ShareParam.SHARE_WECHAT_TIMELINE);
Map.put("image", "imagePath");
MSLDSDK.action(this, SharePath.ROUTE_SHARE_IMAGE, map, new MSLDCallback() {
@Override
Public void onSuccess(String msg, @Nullable Object data) {
Show("share success");
}
@Override
Public void onFail(int code, String msg, @Nullable Object errorData) {
Show("Share failed" + msg);
}
});</code></pre>
<ul>
<li>Share link to WeChat session</li>
</ul>
<pre><code class="language-java"> HashMap<String, Object> map = new HashMap<String, Object>();
Map.put("scene", ShareParam.SHARE_WECHAT_SESSION);
Map.put("thumbImage", WechatUtils.toHexString(getBytes(file));
Map.put("webpageUrl", "Link to share");
Map.put("title", "link title");
Map.put("description", "link description");
MSLDSDK.action(this, SharePath.ROUTE_SHARE_WEBPAGE, map, new MSLDCallback() {
@Override
Public void onSuccess(String msg, @Nullable Object data) {
Show("share success");
}
@Override
Public void onFail(int code, String msg, @Nullable Object errorData) {
Show("Share failed" + msg);
}
});</code></pre>
<ul>
<li>Share links to friends</li>
</ul>
<pre><code class="language-java"> HashMap<String, Object> map = new HashMap<String, Object>();
Map.put("scene", ShareParam.SHARE_WECHAT_TIMELINE);
Map.put("thumbImage", WechatUtils.toHexString(getBytes(file));
Map.put("webpageUrl", "Link to share");
Map.put("title", "link title");
Map.put("description", "link description");
MSLDSDK.action(this, SharePath.ROUTE_SHARE_WEBPAGE, map, new MSLDCallback() {
@Override
Public void onSuccess(String msg, @Nullable Object data) {
Show("share success");
}
@Override
Public void onFail(int code, String msg, @Nullable Object errorData) {
Show("Share failed" + msg);
}
});</code></pre>
<ul>
<li>Share WeChat applet to WeChat session</li>
</ul>
<ol>
<li>Parameter application: Register the small program on [WeChat public platform] (<a href="https://mp.weixin.qq.com/">https://mp.weixin.qq.com/</a>) and get the original id of the small program, specifically contact channel business or technology in the Taiwan-WeChat group.</li>
<li>Note: In the [WeChat Open Platform] (<a href="https://open.weixin.qq.com/">https://open.weixin.qq.com/</a>), bind the WeChat development platform account to the application, and contact the channel business or technology in the Taiwan-WeChat group. .</li>
<li>Call the example:</li>
</ol>
<pre><code class="language-java">HashMap<String, Object> map = new HashMap<String, Object>();
Map.put("userName", "WeChat applet original ID");
Map.put("path", "pages/index");
Map.put("miniprogramType", "0");
Map.put("thumbImage", WechatUtils.toHexString(getBytes(file));
Map.put("webpageUrl", "Shared Link");
Map.put("title", "link title");
Map.put("description", "link description");
Map.put("withShareTicket", "0");
MSLDSDK.action(this, SharePath.ROUTE_SHARE_MINI_PROGRAM, map, new MSLDCallback() {
@Override
public void onSuccess(String msg, @Nullable Object data) {
show("分享成功");
}
@Override
public void onFail(int code, String msg, @Nullable Object errorData) {
show("分享失败 " + msg);
}
});</code></pre>
<ul>
<li>Apply to open WeChat applet</li>
</ul>
<ol>
<li>Parameter application: Register the small program on [WeChat public platform] (<a href="https://mp.weixin.qq.com/">https://mp.weixin.qq.com/</a>) and get the original id of the small program, specifically contact channel business or technology in the Taiwan-WeChat group.</li>
<li>Note: In the [WeChat Open Platform] (<a href="https://open.weixin.qq.com/">https://open.weixin.qq.com/</a>), the WeChat development platform account to which the application belongs should be bound to the small program, specifically to contact the channel business or technical middle platform-WeChat group.</li>
<li>Call the example:</li>
</ol>
<pre><code class="language-java">HashMap<String, Object> map = new HashMap<String, Object>();
Map.put("userName", "WeChat applet original ID");
Map.put("path", "pages/index");
Map.put("miniprogramType", "0");
MSLDSDK.action(this, SharePath.ROUTE_SHARE_LAUNCH_MINI_PROGRAM, map, null);</code></pre>
<h4>4.4 Reporting game data (DLOG SDK)</h4>
<ul>
<li>MSSDK has integrated DLOG SDK data statistics capabilities, the game can report various data, and support visual data reports.</li>
<li>The data reporting function depends on the user function and must be connected to the user function before it can be used.</li>
<li>Call example:
<pre><code class="language-Android">/ / Game loading time
SDKRouter.getInstance().action(getContext(), DlogPath.ROUTE_DLOG_LOADINGCOMPLETED, new HashMap<String, Object>() {
{
Put("loadingTime", 10);
}
}, null);
/ / Custom event flow
SDKRouter.getInstance().action(getContext(), DlogPath.ROUTE_DLOG_CUSTOMEVENTFLOW, new HashMap<String, Object>() {
{
Put("EventId", "event_id_10009000");
Put("EventParam", "register");
Put("EventParamValue", "1");
Put("extStr1", "other_value");
}
}, null);</code></pre></li>
</ul>
<h4>4.5 Others</h4>
<h5>4.5.1 Obtaining configuration information (optional)</h5>
<ul>
<li>Obtain the MSSDK configuration information. MSLDConfig temporarily has only one field isTrial, that is, whether to review the mode.</li>
<li>Call example:</li>
</ul>
<pre><code class="language-java">MSLDConfig config = MSLDSDK.<MSLDConfig>syncAction(activity, RoutePath.ROUTE_SDK_CONFIG, null);</code></pre>
<h4>4.6 Access User (no UI version)</h4>
<ul>
<li>No UI version integration document for access users, please see "MSSDK Integration Document (no UI version)"</li>
</ul>
<h4>4.7 Access Jiguang One-Click Login</h4>
<ul>
<li>Need to access Aurora one-click login, please see "MSSDK Jiguang One-click Login Integrated Documentation"</li>
</ul>
<h4>4.8 Access to Lebain</h4>
<ul>
<li>Need to access the Lebain hot update, please see "MSSDK Lebian Hot Update Integrated Documentation</li>
</ul>