提供页面维度和组件维度可以设置防截屏和录屏API或属性?

提供页面维度和组件维度可以设置防截屏和录屏API或属性?

HarmonyOS
2024-06-04 23:18:25
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
xcbaby

在模块级别 module.json5添加权限 ohos.permission.PRIVACY_WINDOW (module -> requestPermissions)

示例代码:

// 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); 
    }) 
  } 
} 
 
// index.ets 文件 
import common from '@ohos.app.ability.common'; 
import { windowUtils } from '../common/windowUtils'; 
 
struct SwiperExample { 
  onPageShow() { 
    //let windowInstance: window.WindowStage = AppStorage.get("mainWindow") as window.WindowStage; 
    // windowInstance.getMainWindowSync().setWindowPrivacyMode(true);  
    windowUtils.setWindowPrivacyModeInPage(getContext(this) as common.UIAbilityContext, true); 
  } 
 
  onPageHide() { 
    windowUtils.setWindowPrivacyModeInPage(getContext(this) as common.UIAbilityContext, false); 
  } 
 
  build() { 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.

参考链接:

Android 截屏录屏 FLAG_SECURhttps://www.jianshu.com/p/eb0450987280

分享
微博
QQ
微信
回复
2024-06-05 19:54:22


相关问题
页面如何
242浏览 • 0回复 待解决
flutter的页面如何
351浏览 • 1回复 待解决
HarmonyOS 如何
1007浏览 • 1回复 待解决
HarmonyOS 如何禁止
1419浏览 • 1回复 待解决
HarmonyOS 如何设置
1245浏览 • 1回复 待解决
HarmonyOS
763浏览 • 1回复 待解决
HarmonyOS
935浏览 • 1回复 待解决
HarmonyOS 单个页面问题
531浏览 • 1回复 待解决
如何、投
3263浏览 • 1回复 待解决
防止屏幕或者
1435浏览 • 1回复 待解决
HarmonyOS 如何禁用
998浏览 • 1回复 待解决
HarmonyOS 密码登录页面未做
1085浏览 • 1回复 待解决