HarmonyOS 防截屏功能如何实现

防截屏功能如何实现

HarmonyOS
2024-12-20 17:04:39
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zbw_apple

参考demo:

aboutToDisappear(): void {
  let windowClass: window.Window | undefined = undefined;
  window.getLastWindow(getContext(this)).then((win) => {
  this.window = win
})
window.getLastWindow(getContext(this), (err: BusinessError, data) => {
  const errCode: number = err.code;
  if (errCode) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
    return;
  }
  windowClass = data;
  console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
  setWindowPrivacyMode(windowClass, true)
});
}


export function setWindowPrivacyMode(windowClass: window.Window, isPrivacyMode: boolean) {
  // try {
  windowClass.setWindowPrivacyMode(isPrivacyMode
    /*, (err: BusinessError) => {
    if (err) {
      console.error('Failed to set the window to the privacy mode. Cause:'+ JSON.stringify(err));
      return;
    }
    console.info('Succeeded in setting the window to the privacy mode.');
  }*/
  );
  console.info(`setWindowPrivacyMode 已执行`);
  // } catch (exception) {
  //   console.error('Failed to set the window to the privacy mode. Cause:'+ JSON.stringify(exception));
  // }
}
分享
微博
QQ
微信
回复
2024-12-20 18:48:19
相关问题
求告知如何实现功能
773浏览 • 1回复 待解决
求大佬告知如何实现功能
2255浏览 • 1回复 待解决
如何实现功能,有人知道吗?
2218浏览 • 1回复 待解决
HarmonyOS 如何
521浏览 • 1回复 待解决
HarmonyOS
455浏览 • 1回复 待解决
HarmonyOS 单个页面问题
199浏览 • 1回复 待解决
HarmonyOS分享功能实现
315浏览 • 1回复 待解决
HarmonyOS 密码登录页面未做
640浏览 • 1回复 待解决
HarmonyOS 应用内防功能
282浏览 • 1回复 待解决
HarmonyOS 是否有功能
532浏览 • 1回复 待解决
HarmonyOS 不被或者录如何实现
282浏览 • 1回复 待解决
HarmonyOS如何实现当前禁止
1093浏览 • 1回复 待解决
HarmonyOS如何实现当前禁止
352浏览 • 0回复 待解决
如何、录、投
2384浏览 • 1回复 待解决
HarmonyOS
385浏览 • 1回复 待解决
HarmonyOS 如何禁用、录
546浏览 • 1回复 待解决