问题描述
我正在开发基于 Accessibility
功能的 Android
APP.因为它不能在 Android 中以编程方式启用/禁用辅助功能
服务(见 How to Programmatically Enable/Disable Accessibility Service in Android) ,所以我通过下面的代码引导用户到Accessibility Settings
页面(图1):
I am developing an Android
APP based on Accessibility
feature. As it can't programmatically Enable/Disable Accessibility
Service in Android(See How to Programmatically Enable/Disable Accessibility Service in Android) , So I guide the user to Accessibility Settings
Page(Pic 1) via the code below:
public static boolean gotoAccessibilitySettings(Context context) {
Intent settingsIntent = new Intent(
Settings.ACTION_ACCESSIBILITY_SETTINGS);
if (!(context instanceof Activity)) {
settingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
boolean isOk = true;
try {
context.startActivity(settingsIntent);
} catch (ActivityNotFoundException e) {
isOk = false;
}
return isOk;
}
然后用户需要找到我的APP的子设置标签,点击它,现在我的APP的Accessibility Settings
页面显示(图2).
And then the user need to find out the Sub Settings Label of my APP, click it, and now the Accessibility Settings
Page of my APP show(Pic 2).
我怀疑是否可以直接启动我的APP的Accessibility Settings
页面(图2)?
I doubt that if any way start my APP's Accessibility Settings
Page(Pic 2) directly?
推荐答案
也许下面的代码可以帮到你:
Maybe the code below can help you :
Intent intent = new Intent();
intent.setClassName("com.android.settings",
"com.android.settings.Settings");
intent.setAction(Intent.ACTION_MAIN);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
"the fragment which you want show");
intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS,
extras);
startActivity(intent);
或者您可以搜索关键词片段注入"了解更多信息;查看此链接,它对您有用:
Or you can search the Key Word "Fragment Injection" for more information;Check out this link,it is useful for you case:
这篇关于如何在 Android 中启动我的 APP 的辅助功能设置页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!