自定义相机照片拍摄后,点击左下角拍摄的图片不是直接打开,而是跳转到图库。
Image(this.finalPixelMap)
.height(50)
.width(50)
.borderRadius(50)
.onClick(() => {
skipToAlbum(this.photoUri)
})
async skipToAlbum(uriPath: string) {
try {
// 推荐替代方案(API 18+)
let context = this.getUIContext().getHostContext() as common.UIAbilityContext;
let bundleInfo: bundleManager.BundleInfo =
await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
let wantInfo: Want = {
bundleName: 'com.huawei.hmos.photos',
abilityName: 'com.huawei.hmos.photos.MainAbility',
uri: 'application_info_entry',
parameters: {
pushParams: bundleInfo.name // app的bundleName也就是包名
}
};
context.startAbility(wantInfo).then(() => {
// 成功
}).catch(() => {
// 失败
});
} catch (error) {
let err: BusinessError = error as BusinessError;
console.error('失败了', err.message);
}
}