密码输入可视化界面禁用截屏录屏的实现,请参考以下步骤和demo:1、在module.json5文件中声明需要使用的ohos.permission.PRIVACY\_WINDOW权限,参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/declare-permissions-V5"requestPermissions":[ { "name" : "ohos.permission.PRIVACY_WINDOW" } ]2、示例代码:// windowUtils.ets import window from '@ohos.window'; import common from '@ohos.app.ability.common'; export class windowUtils { static setWindowPrivacyModeInPage(context: common.UIAbilityContext,isFlag: boolean) { window.getLastWindow(context).then((lastWindow)=>{ lastWindow.setWindowPrivacyMode(isFlag); }) } } //页面 import common from '@ohos.app.ability.common'; import { windowUtils } from '../common/windowUtils'; @Entry @Component struct Index3 { @State message: string = 'Hello World'; onPageShow(): void { windowUtils.setWindowPrivacyModeInPage(getContext(this) as common.UIAbilityContext, true); } onPageHide() { windowUtils.setWindowPrivacyModeInPage(getContext(this) as common.UIAbilityContext,false); } build() { Row() { Column() { Text(this.message) .fontSize(50) .fontWeight(FontWeight.Bold) } .width('100%') } .height('100%') } }防止App录屏或截屏可以通过@ohos.window的setWindowPrivacyMode将窗口设置为隐私模式,隐私模式下的窗口,窗口内容将无法被截屏或录屏具体使用可以参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-window-V5\#setwindowprivacymode9
密码输入可视化界面禁用截屏录屏的实现,请参考以下步骤和demo:
1、在module.json5文件中声明需要使用的ohos.permission.PRIVACY\_WINDOW权限,参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/declare-permissions-V5
2、示例代码:
防止App录屏或截屏可以通过@ohos.window的setWindowPrivacyMode将窗口设置为隐私模式,隐私模式下的窗口,窗口内容将无法被截屏或录屏
具体使用可以参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-window-V5\#setwindowprivacymode9