Android 10.0 fixes the default browser function after installing another browser after setting the default browser

1 Introduction


In the 10.0 system rom customization development, when there are multiple browsers in the system, when the browser is enabled with code, the user will be asked to choose which browser to enter, which is particularly inconvenient, so the product
development , it is required to use the relevant API of RoleManager to set the default browser, but after setting the default browser, when installing a browser, the default browser will be invalid, and the browser option in the default application of the system setting
is Empty, the default browser list will pop up when the browser is enabled with code, allowing you to choose which default browser to enter. Therefore, it is necessary to analyze the relevant settings from the process of installing the browser
. to solve the problem


Set the relevant code of the default browser

    private void setDefaultApplication(String roleName, String packageName) {
        RoleManager roleManager = mContext.getSystemService(RoleManager.class);
        Executor executor = mContext.getMainExecutor();
        Consumer<Boolean> callback = successful -> {
            if (successful) {
                Log.e(TAG, "setDefaultApplication packageName:"+packageName+" successful");
            }
        };
        roleManager.a

Guess you like

Origin blog.csdn.net/baidu_41666295/article/details/130451174