如何直接打开我的应用程序的辅助功能设置?

时间:2015-08-04 06:57:24

标签: android accessibilityservice

如上所述:How can I start the Accessibility Settings Page of my APP in Android? 我可以使用以下代码直接打开我的应用程序辅助功能设置:

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

但我测试了很多东西,比如app name,package name,service class name等,而不是"你要显示的片段"但没有用。

2 个答案:

答案 0 :(得分:0)

仅在kitkat 4.4以下工作。此漏洞问题已在4.4及更高版本中解决。 可访问性权限是至关重要的权限之一,而android不允许您直接访问该应用程序页面,因为目前只有打开可访问性服务的方法是

startActivity(new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS))

然后,如果用户想允许其权限,则可以选择您的应用

答案 1 :(得分:-1)

像这样:

Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivityForResult(intent, 0);