[英]How to turn off the capacitive buttons light on Samsung devices programmatically?
I need to turn off the capacitive buttons light in my app. 我需要在我的应用程序中关闭电容式按钮灯。
I found this popular implementation 我找到了这个流行的实现
Settings.System.putInt(getContentResolver(), "button_key_light", 0);
Sadly, I get this exception on more recent Samsung devices 可悲的是,我在最近的三星设备上遇到了这个例外
java.lang.IllegalArgumentException: You cannot keep your settings in the secure settings.
Is there a known way to implement something like this? 有没有一种已知的方法来实现这样的东西?
I have found this app and it seems to work fine with even the most recent devices, so I tried to decompile it and could only find the same line of code I mentioned above, which I really don't understand. 我找到了这个应用程序 ,它似乎与最新的设备工作正常,所以我试图反编译它,只能找到我上面提到的相同代码行,我真的不明白。 Maybe the decompilation process changed a saved String in the system to "button_key_light"?
也许反编译过程将系统中保存的String更改为“button_key_light”?
Maybe it's because of more recent build tools? 也许是因为更新的构建工具?
So does anyone have a known way of getting it to work? 那么有没有人知道如何让它发挥作用? Or at least an explanation for why my current code doesn't work?
或至少解释为什么我当前的代码不起作用?
OK I figured this out. 好的,我想出来了。
It seems like you have to target sdk version 22 or lower to write system settings that are not predefined. 您似乎必须以sdk 22或更低版本为目标来编写未预定义的系统设置。
So in order to run 所以为了奔跑
Settings.System.putInt(getContentResolver(), "button_key_light", 0);
You have to add this to your app build.gradle 您必须将此添加到您的应用build.gradle
defaultConfig {
...
targetSdkVersion 22
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.