HarmonyOS5-NewsAPP-SystemShare

4 months ago 5

HarmonyOS 5 News Application - System Sharing Function Implementation Case Summary This article details the implementation of the system sharing function in a HarmonyOS 5.0 news application. By using the BarButton component and the systemShare module, the sharing function of news links is achieved.

BarButton({ icon: $r('sys.media.ohos_ic_public_share') }) .onClick(() => { // system share const data = new systemShare.SharedData({ utd: uniformTypeDescriptor.UniformDataType.HYPERLINK, title: 'NewsAPP', content: ' `https://edition.cnn.com/` ' }) const controller = new systemShare.ShareController(data) const ctx = this.getUIContext().getHostContext() as common.UIAbilityContext controller.show(ctx, { previewMode: systemShare.SharePreviewMode.DETAIL, selectionMode: systemShare.SelectionMode.SINGLE }) })

Read Entire Article