本文介绍了在Android中以编程方式更改“模拟色彩空间"和其他开发人员选项(已解决)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在我的应用程序中修改开发人员选项设置,我曾尝试在Settings.Global,Settings.System和Settings.Secure中查找,但是没有一个覆盖我要使用的特定切换,即模拟颜色空间".

有人能够指出正确的方向来尝试查找此设置提供程序吗?

解决方案

好消息!,我现在已经解决了!(需要 ROOT ADB )

请注意,要成功修改安全设置,您必须向 android.permission.WRITE_SECURE_SETTINGS 授予您的应用权限,否则它将崩溃;您可以通过两种方式执行此操作,或者通过ADB Shell:" pm授予your.package.name android.permission.WRITE_SECURE_SETTINGS ",或者通过请求root特权并在您的应用程序中将其作为SU执行./p>

使用以下几行启用单色设置:

  Settings.Secure.putString(this.getContentResolver(),"accessibility_display_daltonizer_enabled","1");Settings.Secure.putString(this.getContentResolver(),"accessibility_display_daltonizer","0"); 

并禁用:

  Settings.Secure.putString(this.getContentResolver(),"accessibility_display_daltonizer_enabled","0");Settings.Secure.putString(this.getContentResolver(),"accessibility_display_daltonizer","-1"); 

我将这些字符串常量放置在Settings.Secure类中,您将能够找到其他开发人员设置并将其修改为自己喜欢的样式.

以下是其他屏幕空间模式的值:

  DISABLED = -1单色= 0比例= 11CORRECT_DEUTERANOMALY = 12TRITANOMALY = 13 

享受!

I am looking to be able to modify developer option settings in my app, I have tried looking in the Settings.Global, Settings.System and Settings.Secure but none cover the specific toggle I'm after, which is "Simulate color space".

Would anyone be able to point me in the right direction in trying to locate this setting provider?

解决方案

Great news!, I have solved this now! (Requires ROOT or ADB)

Please note, to successfully modify secure settings you must grant your app permission to android.permission.WRITE_SECURE_SETTINGS otherwise it will crash; you can do this in two ways, either from the ADB Shell: "pm grant your.package.name android.permission.WRITE_SECURE_SETTINGS" or by requesting root privileges and executing it within your app as SU.

Use the following lines to enable the Monochrome setting:

Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer_enabled", "1");
Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer", "0");

and to disable:

Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer_enabled", "0");
Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer", "-1");

I located these string constants in the Settings.Secure class and you will be able to find other developer settings and modify them to your fancy.

Below are the values for the other screen-space modes:

DISABLED = -1
MONOCHROMACY = 0
PROTANOMALY = 11
CORRECT_DEUTERANOMALY = 12
TRITANOMALY= 13

Enjoy!

这篇关于在Android中以编程方式更改“模拟色彩空间"和其他开发人员选项(已解决)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 16:09