FLAG_SECURE在libgdx的AndroidApplication上不起作用 [英] FLAG_SECURE not working on libgdx's AndroidApplication

查看:571
本文介绍了FLAG_SECURE在libgdx的AndroidApplication上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在libGDX的帮助下创建的Android游戏.我想禁用截图功能.

I have an Android game created with help of libGDX. I want to disable the ability to take screenshots.

对于常规的android活动,您可以使用getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);方法.效果很好.

For regular android activities you can use getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE); method. It works fine.

但是它不适用于从com.badlogic.gdx.backends.android.AndroidApplication扩展的活动.我仍然可以拍摄屏幕截图.

But it doesn't work with activities extended from com.badlogic.gdx.backends.android.AndroidApplication. I'm still able to take screenshots.

有什么想法吗?

推荐答案

在AndroidApplication中调用initialize会设置全屏游戏的窗口参数,因此它会覆盖您的窗口参数.因此,将其放在onCreate 之后,称为initialize.请注意,您应该使用addFlags而不是setFlags,以免弄乱Libgdx设置的其他标志.

Calling initialize in AndroidApplication sets up the window parameters for a full-screen game, so it's overwriting your window parameters. So instead, put this in onCreate after you call initialize. Note that you should use addFlags instead of setFlags so you don't mess up the other flags that Libgdx set.

getWindow().addFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);

这篇关于FLAG_SECURE在libgdx的AndroidApplication上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆