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

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

问题描述

如何以编程方式启用/禁用 Android 屏幕阅读器服务,例如 TalkBack?

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 中以编程方式启用/禁用无障碍服务

推荐答案

只有系统应用才能以编程方式启用/禁用无障碍服务.系统应用可以直接写入设置安全数据库启动无障碍服务.

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

在设置安全数据库中写入需要以下权限:

Following permission is required to write in settings secure db:

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

对于非系统应用,启动无障碍服务的唯一方法是通过意图将它们引导至无障碍设置屏幕并让用户手动启动服务:

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天全站免登陆