How can I start the Accessibility Settings Page of

2019-01-24 03:44发布

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

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

I doubt that if any way start my APP's Accessibility Settings Page(Pic 2) directly?

3条回答
一夜七次
2楼-- · 2019-01-24 04:00

You can manually open the accessibility settings with the following Intent (when android.content.Intent and android.app.Intent have both been imported):

Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivity(intent);

Check out the following resources for more information:

查看更多
SAY GOODBYE
3楼-- · 2019-01-24 04:09

You can directly open the accessibility settings page from settings app using the Intent to android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS To do so, you can start the Accessibility settings by passing intent as,

startActivityForResult(new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS), INTENT_CODE);

and it will return the result of settings in onActivityResult() of the caller activity by result code as INTENT_CODE. you can check the accessibility setting for your app is allowed or not.

查看更多
forever°为你锁心
4楼-- · 2019-01-24 04:18

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:

查看更多
登录 后发表回答