FLAG_SECURE not working on libgdx's AndroidApplication

回眸只為那壹抹淺笑 提交于 2019-12-10 18:16:43

问题


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

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

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

Any ideas?


回答1:


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);


来源:https://stackoverflow.com/questions/33941381/flag-secure-not-working-on-libgdxs-androidapplication

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!