HarmonyOS 鸿蒙Next如何直接跳转到本地音频文件页面,如点击按钮直接跳转到图库
HarmonyOS 鸿蒙Next如何直接跳转到本地音频文件页面,如点击按钮直接跳转到图库 如何直接跳转到本地音频文件页面,如点击按钮直接跳转到图库?
2 回复
应用间相互跳转可以参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/link-between-apps-overview-V5
可以参考下述跳转地图的demo:
import common from '@ohos.app.ability.common';
import { BusinessError } from '@ohos.base';
function startMapDialog(context: common.UIAbilityContext): void {
context.startAbility({
bundleName: 'com.amap.hmapp',
abilityName: 'EntryAbility'
}).then(() => {
console.info('successfully.');
}).catch((err: BusinessError) => {
console.error(`Failed Code: ${err.code}, message: ${err.message}`);
});
}
@Entry
@Component
struct gaodeMap {
@Provide('pageInfo') pageInfo: NavPathStack = new NavPathStack()
build() {
Navigation(this.pageInfo) {
Column() {
Button('高德地图', { stateEffect: true, type: ButtonType.Capsule })
.width('80%')
.height(40)
.margin(20)
.onClick(() => {
let context = getContext(this) as common.UIAbilityContext;
startMapDialog(context);
})
}.width('100%')
}.title('NavIndex')
}
}
通过选择模式拉起audioPicker界面 参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V2/js-apis-file-picker-0000001493424372-V2#ZH-CN_TOPIC_0000001574088417__select-6
import picker from '@ohos.file.picker';
AudioSelect() {
const AudioSelectOptions = new picker.AudioSelectOptions();
const audioPicker = new picker.AudioViewPicker();
audioPicker.select(AudioSelectOptions).then((AudioSelectResult) => {
console.info('AudioViewPicker.select successfully, AudioSelectResult uri: ' + JSON.stringify(AudioSelectResult));
}).catch((err) => {
console.error('AudioViewPicker.select failed with err: ' + err);
});
}
更多关于HarmonyOS 鸿蒙Next如何直接跳转到本地音频文件页面,如点击按钮直接跳转到图库的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html