我正在尝试在应用程序启动后立即为我的应用程序启用辅助功能设置。但我目前无法做到这一点。我使用了以下代码:
Settings.Secure.putString(getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
"package_name");
Settings.Secure.putString(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED,
"1");
要使用此代码 fragment ,我们必须声明以下权限:
WRITE_SECURE_SETTINGS,但此权限仅适用于系统应用程序。我怎样才能为我的应用程序实现相同的功能。欢迎提出所有建议。
最佳答案
API 表示:Settings.Secure是
for preferences that the user must explicitly modify through the system UI or specialized APIs for those values, not modified directly by applications.
如果您想以编程方式检查以提示用户,另请参阅 android-how-do-you-check-if-a-particular-accessibilityservice-is-enabled .调用 Intent 的代码在 how-to-programmatically-enable-disable-accessibility-service-in-android 中给出,例如, 这是
Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS); startActivityForResult(intent, 0);
关于android - 如何在应用程序启动后立即为我的应用程序启用辅助功能设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32010220/