s***@sina.com
s***@sina.com
  • 发布:2018-01-22 10:49
  • 更新:2020-07-22 17:19
  • 阅读:2963

你好 请问一下 如何防止登陆界面截屏和录屏

分类:HBuilder

在html中编写了登陆界面和忘记密码界面,在android端或HBuider中如何设置才能防止登陆界面截屏和录屏呢?

2018-01-22 10:49 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com

https://ext.dcloud.net.cn/plugin?id=1886

......
<button @click="ssTestScreenShotCloseFunc">禁止截屏/录屏
......
methods: {
......
ssTestScreenShotCloseFunc:function(){
const ssTest = uni.requireNativePlugin('hsj-screenshothsj');
ssTest.screenShotClose({'msg':'开启禁止截屏/录屏 ...'},
result =>{
switch (result.type){
case 0:
console.log(result.data.toString())
break;
default:
console.log("no have type")
}
}
);
}
......
}

猫猫猫猫

猫猫猫猫 - 用户已离线

监听本地文件的变化,当发现新增的文件特征接近截屏和录屏的时候,删除。
监听这部分最好用离线原生写插件方式,native.js 写不方便。

下雨咯

下雨咯 - 谢绝私聊

在要禁止截屏的页面

document.addEventListener( "plusready", function(){  
        var activity = plus.android.runtimeMainActivity();  
        plus.android.invoke(plus.android.invoke(activity,"getWindow"),"addFlags",0x00002000);  
    }, false );
s***@sina.com

s***@sina.com (作者)

在登陆界面的html中写以下代码可防止android手机截屏
var main = plus.android.runtimeMainActivity();
var window = plus.android.importClass("android.view.Window");
main.getWindow().addFlags(0x00002000);
不需要截屏时,移除即可
var main = plus.android.runtimeMainActivity();
var window = plus.android.importClass("android.view.Window");
main.getWindow().clearFlags(0x00002000);

  • lancetest

    现在执行会报错


    [JS Framework] Failed to execute the callback function:

    23:45:25.108 android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.;at com.android.internal.policy.impl.PhoneWindow.addFlags

    23:45:25.210 reportJSException >>>> exception function:WEEX_CALL_JAVASCRIPT, exception:JavaScript execute error!android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.;at com.android.internal.policy.impl.PhoneWindow.addFlags

    23:45:25.230 getTemplateInfo== template md5 b7e83db7e3dd9cb3cbf4d638f5e74625 length 3546550 base64 md5 t+g9t+PdnLPL9NY49edGJQ== response header {"templateSourceBase64MD5":["t+g9t+PdnLPL9NY49edGJQ=="],"templateSourceMD5":["b7e83db7e3dd9cb3cbf4d638f5e74625"]}

    2019-12-20 10:57

lancetest

lancetest

现在执行会报错

[JS Framework] Failed to execute the callback function:
23:45:25.108 android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.;at com.android.internal.policy.impl.PhoneWindow.addFlags
23:45:25.210 reportJSException >>>> exception function:WEEX_CALL_JAVASCRIPT, exception:JavaScript execute error!android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.;at com.android.internal.policy.impl.PhoneWindow.addFlags
23:45:25.230 getTemplateInfo== template md5 b7e83db7e3dd9cb3cbf4d638f5e74625 length 3546550 base64 md5 t+g9t+PdnLPL9NY49edGJQ== response header {"templateSourceBase64MD5":["t+g9t+PdnLPL9NY49edGJQ=="],"templateSourceMD5":["b7e83db7e3dd9cb3cbf4d638f5e74625"]}

3***@qq.com

3***@qq.com

已经搞定了,安卓是 禁止写入 ; IOS是监听屏幕录制。
刚弄好。

  • 4***@qq.com

    您是用的插件吗 还是有api 就可以直接 监听到呢

    2021-03-04 14:04

要回复问题请先登录注册