Android进入设置中应用对应的详情界面

有时候为了引导用户操作,例如手动赋予权限等,需要拉起应用对应的详情界面。

此时,可以使用Settings中定义的ACTION_APPLICATION_DETAILS_SETTINGS。
源码中的描述如下:

..............
    /**
     * Activity Action: Show screen of details about a particular application.
     * <p>
     * In some cases, a matching Activity may not exist, so ensure you
     * safeguard against this.
     * <p>
     * Input: The Intent's data URI specifies the application package name
     * to be shown, with the "package" scheme.  That is "package:com.my.app".
     * <p>
     * Output: Nothing.
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_APPLICATION_DETAILS_SETTINGS =
            "android.settings.APPLICATION_DETAILS_SETTINGS";
................

具体使用时的代码类似于:

............
    public static final String SETTINGS_ACTION =
            "android.settings.APPLICATION_DETAILS_SETTINGS";
..............
    mSetPermissionView.setOnClickListener(new View.OnClickListener() {
        @Override
            public void onClick(View v) {
                Intent intent = new Intent()
                        .setAction(SETTINGS_ACTION)
                        .setData(Uri.fromParts("package",
                                getActivity().getPackageName(), null));
                startActivity(intent);
            }
        });
 ................

Intent携带数据格式为pacakge:包名,类似于:

package:stark.a.is.zhang.transfer
©️2020 CSDN 皮肤主题: 代码科技 设计师:Amelia_0503 返回首页