import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';
let isPrivacyMode: boolean = true;
let windowClass: window.Window = window.findWindow("test");
try {
windowClass.setWindowPrivacyMode(isPrivacyMode, (err: BusinessError) => {
const errCode: number = err.code;
if (errCode) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the window to privacy mode.');
});
} catch (exception) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
}
setWindowPrivacyMode设置窗口是否为隐私模式,设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。此接口可用于禁止截屏/录屏的场景。具体可参考示例代码:
参考链接
setWindowPrivacyMode