本文介绍了禁用带代码的对讲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我为盲人创建了一个应用程序.它以文字转语音的方式运行.当我打开对讲时,我的应用程序无法运行,并锁定在徽标屏幕上.我要寻找的是当我的应用运行对讲时将停止.
I built an application for blind people. It runs with text to speech. When I open talkback, my app does not run, lockes on logo screen. What I looking for is when my app runs talkback would stop.
推荐答案
除非已获得系统权限 WRITE_SECURE_SETTINGS
(通过ADB),否则无法在应用程序内打开或关闭话语提示"由用户.
It's not possible to turn TalkBack on or off from within your app unless you have been granted the system permission WRITE_SECURE_SETTINGS
(via ADB) by the user.
private static final String TALKBACK_SERVICE_NAME = "com.google.android.marvin.talkback/.TalkBackService";
private void updateTalkBackState(boolean enableTalkBack) {
if (enableTalkBack) {
enableAccessibilityService(TALKBACK_SERVICE_NAME);
} else {
disableAccessibilityServices();
}
}
private void enableAccessibilityService(String name) {
Settings.Secure.putString(getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, name);
Settings.Secure.putString(getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, VALUE_ENABLED);
}
private void disableAccessibilityServices() {
Settings.Secure.putString(getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "");
Settings.Secure.putString(getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, VALUE_DISABLED);
}
这篇关于禁用带代码的对讲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!