Integrate the Social Share SDK into your Android project to enable sharing to Weibo, WeChat, Alipay, QQ, DingTalk, and SMS.
Overview
The Social Share component provides a unified sharing interface across multiple channels — Weibo, WeChat, Alipay, QQ, DingTalk, and SMS — so you don't need to handle the API differences between each platform's SDK. Integration requires adding the share component and configuring per-platform settings in your Android project.
Two integration methods are available:
Native AAR integration: add the SDK directly as an AAR dependency. Complete the steps in Add mPaaS to your project first.
Component-based integration: manage the SDK through your Portal and Bundle projects. Complete the component-based integration process first.
Prerequisites
Register a developer account on each platform you want to support:
Add the SDK
Native AAR integration
Follow Manage AAR components and use Component Management (AAR) to install the Share component.
Important
As of version 10.2.3.76, the Social Share component no longer bundles the Weibo SDK. If you need to use the Weibo SDK, add the official Weibo SDK explicitly to avoid compilation errors:
dependencies {
implementation "io.github.sinaweibosdk:core:13.10.8@aar"
}
configurations.all {
resolutionStrategy {
exclude group:'com.sina.weibo.sdk', module: 'core'
exclude group:'com.alipay.android.phone.mobilecommon',module:'share_weibo'
}
}
To keep using the older Weibo sharing feature without the Weibo SDK, pin the legacy build instead:
configurations.all {
resolutionStrategy {
force 'com.alipay.android.phone.mobilecommon:share-build:1.3.0.250721165359'
}
}
Component-based integration
In your Portal and Bundle projects, use Component Management to install the Share component. See Manage component dependencies for details.
Initialize mPaaS
For native AAR integration, initialize mPaaS in your Application class:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Initialize mPaaS
MP.init(this);
}
}
For full initialization options, see Initialize mPaaS.
Platform-specific configurations
The examples below use the official Social Share demo with baseline 10.1.32 and later.
WeChat sharing
Create an Activity to receive WeChat Share callbacks. This Activity must extend DefaultWXEntryActivity and be placed at the path package_name.wxapi.WXEntryActivity, where package_name is your application's package name.
The path and Activity name must be exact. An incorrect path means no callbacks are received.
For a project with package name com.mpaas.demo:
package com.mpaas.demo.wxapi;
import com.alipay.android.shareassist.DefaultWXEntryActivity;
public class WXEntryActivity extends DefaultWXEntryActivity {
}
Register the Activity in AndroidManifest.xml:
<application>
···
<activity android:name="com.mpaas.demo.wxapi.WXEntryActivity"
android:exported="true"
android:launchMode="singleTop">
</activity>
···
</application>
Keep share icons under 32 KB. The Android SDK rejects oversized icons and replaces them with the default Alipay icon, which may cause WeChat sharing to fail.
QQ and QZone sharing
Register the QQ sharing Activity in AndroidManifest.xml. Without this registration, QQ and QZone sharing and callbacks do not work.
The QQ Share ID in
AndroidManifest.xmlmust match the ID registered in your code. A mismatch causes theonExceptioncallback to fire even on successful shares.In the
data android:schemefield, enter the QQ Share ID in the formattencent+QQIDwithout the plus sign (+). Apply for this ID on the Tencent Open Platform. For example:tencent1104122330.
<application>
···
<activity
android:name="com.tencent.connect.common.AssistActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<activity
android:name="com.tencent.tauth.AuthActivity"
android:launchMode="singleTask"
android:exported="true"
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"/>
<data android:scheme="tencent1104122330"/>
</intent-filter>
</activity>
···
</application>
Weibo sharing
The app signature, package name, and Share ID must match the information registered on the Weibo Open Platform. A mismatch causes sharing to fail silently: the share component fires onComplete instead of onException. This is a known defect in the Weibo SDK that also affects the official Weibo SDK demo.
Related links
For code samples and usage details, see Obtain code samples.
-
Related API documentation: