@Override protected void initView() { helper = new PermissionHelper(this); helper.setOnApplyPermissionListener( new PermissionHelper.OnApplyPermissionListener() { @Override public void onAfterApplyAllPermission() { runApp(); } }); if (Build.VERSION.SDK_INT < 23) { // 23以后的权限需要申请 runApp(); } else { if (helper.isAllRequestedPermissionGranted()) { // 已经全部授权 runApp(); } else { helper.applyPermissions(); } } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); helper.onActivityResult(requestCode, resultCode, data); }
@Override public void onRequestPermissionsResult( int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); helper.onRequestPermissionsResult(requestCode, permissions, grantResults); }