Sharing UI BizBundle

Last Updated on : 2024-01-12 03:08:16download

Sharing UI BizBundle provides the capabilities to share resources with third parties by means such as SMS, email, or WeChat.

Functional description

  • Sharing by WeChat: An account registered in mainland China and WeChat appkey are required.
  • Sharing by SMS: The SMS feature is implemented. Users can select the target contacts and send them the content to be shared.
  • Copy and share: The content to be shared is automatically copied.
  • Share by email or system application: After the dialog box for system application-based sharing appears, select the target application to share resources.
  • Text sharing: A file content can be shared through a system application.
  • Image sharing: An image specified by imagePath can be shared through a system application.

Integrate with the UI BizBundle

Add the following dependencies to the file build.gradle of module:

dependencies {
    api enforcedPlatform("com.thingclips.smart:thingsmart-BizBundlesBom:5.8.0")
    api 'com.thingclips.smart:thingsmart-bizbundle-share'
    api "com.tencent.mm.opensdk:wechat-sdk-android-without-mta:6.7.0"
}

Share by WeChat

Configure the key

Add the following configurations to the res:

   <string name="wxAppKey">WeChat key</string>

Use the feature

// Shares resources by WeChat.
val mShareManager = MicroContext.getServiceManager().findServiceByInterface<AbsShareManager>(AbsShareManager::class.java.name)

// Initializes the WeChat app.
mShareManager?.initWxShare(wxAppId)

// Checks whether WeChat is installed.
mShareManager?.isWxInstalled()

Share by SMS

val mShareManager = MicroContext.getServiceManager().findServiceByInterface<AbsShareManager>(AbsShareManager::class.java.name)
mShareManager?.doShareBySms(mContext, "share content")

Copy and share resources

val mShareManager = MicroContext.getServiceManager().findServiceByInterface<AbsShareManager>(AbsShareManager::class.java.name)
mShareManager?.doShareByCopy("share content")

Share an image

val mShareManager = MicroContext.getServiceManager().findServiceByInterface<AbsShareManager>(AbsShareManager::class.java.name)
mShareManager?.doShareByImage(mActivity, “mImagePath”)

Share by email

  • Checks whether an email address exists.

    val mShareManager = MicroContext.getServiceManager().findServiceByInterface<AbsShareManager>(AbsShareManager::class.java.name)
    mShareManager?.checkEmailApkExist()
    
  • Shares resources by email.

    val mShareManager = MicroContext.getServiceManager().findServiceByInterface<AbsShareManager>(AbsShareManager::class.java.name)
    mShareManager?.doShareByEmail(mActivity, “mShareTitle”, "share content", “mEmailUrl”)
    

Share by system email

val mShareManager = MicroContext.getServiceManager().findServiceByInterface<AbsShareManager>(AbsShareManager::class.java.name)
mShareManager?.doShareByEmail(mContext,"share content")

Share by all system applications

val mShareManager = MicroContext.getServiceManager().findServiceByInterface<AbsShareManager>(AbsShareManager::class.java.name)
mShareManager?.doShareBySystemDefault(mContext, "share content")

Share by a specified type of application

val mShareManager = MicroContext.getServiceManager().findServiceByInterface<AbsShareManager>(AbsShareManager::class.java.name)
mShareManager?.launchSharePlatform(this, ShareType.TYPE_MORE, "share content")