以编程方式在Android设备上启用/禁用辅助功能设置 [英] Programmatically enabling/disabling accessibility settings on Android device

查看:474
本文介绍了以编程方式在Android设备上启用/禁用辅助功能设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何以编程方式启用/禁用诸如话语提示之类的android屏幕阅读器服务?

How can I programmatically enable/disable an android screen reader service such as TalkBack?

我正在开发一个信息亭类型的应用程序,该应用程序将安装在具有以下功能的Android设备上将在游客参观特定博物馆时借给他们。 (我们仍在确定将使用哪种设备。)该计划仅允许用户使用我们的应用,而无权访问android设置应用。但是,我们希望允许用户配置一些辅助功能设置。在设备完成使用后,我们需要将所有设置恢复为默认设置。

I am developing a kiosk type application that will be installed on an Android device that will be loaned to visitors while they visit a particular museum. (We are still in the process of determining what device we will use.) The plan is to only allow users to use our app and not have access to the android settings application. However, we'd like to allow users to configure some accessibility settings. When they are finished with the device, we need to restore all the settings to our defaults.

下面的链接中的讨论建议启动Android的设置应用。但是我们不希望用户访问许多其他设置。

The discussion at the link below has many suggesting launching Android's Settings app. But we don't want users accessing many other settings.

如何以编程方式在Android中启用/禁用辅助功能

推荐答案

只有系统应用才能以编程方式启用/禁用辅助功能。
系统应用程序可以直接写入设置安全db以启动辅助功能。

Only system apps can enable/disable accessibility service programatically. System apps can directly write in settings secure db to start accessibility service.

Settings.Secure.putString(getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "com.packagename/com.packagename.componentname");

需要在设置安全db中写入以下权限:

Following permission is required to write in settings secure db:

<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />

对于非系统应用程序,唯一启动可访问性服务的方法是通过intent和让用户手动启动该服务:

For non system apps, only way to start accessibility service is direct them to accessibility settings screen via intent and let user manually start the service :

Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);

这篇关于以编程方式在Android设备上启用/禁用辅助功能设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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