动态权限申请
程序员文章站
2022-08-20 11:20:13
//图片选择器implementation 'com.github.dida-logistics:SkinGallery:1.0.0'implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.2.3'import android.Manifest;import android.os.Bundle;import androidx.annotation.Nullable;import androidx......
//图片选择器 implementation 'com.github.dida-logistics:SkinGallery:1.0.0' implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.2.3'
import android.Manifest; import android.os.Bundle; import androidx.annotation.Nullable; import androidx.fragment.app.FragmentActivity; import com.luck.picture.lib.permissions.Permission; import com.luck.picture.lib.permissions.RxPermissions; import io.reactivex.functions.Consumer; public class CheckPermissionsActivity extends FragmentActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); checkPermissions(); } /* * 检测权限 */ private void checkPermissions() { try { RxPermissions rxPermission = new RxPermissions(this); rxPermission.requestEach(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CHANGE_WIFI_STATE, Manifest.permission.CHANGE_NETWORK_STATE, Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.BLUETOOTH, Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.CALL_PHONE, Manifest.permission.CAMERA, Manifest.permission.READ_PHONE_STATE, Manifest.permission.REQUEST_INSTALL_PACKAGES ) .subscribe(new Consumer<Permission>() { @Override public void accept(Permission permission) { if (permission.granted) {// 用户已经同意该权限 } else { } } }); } catch (Exception e) { e.printStackTrace(); } } }
本文地址:https://blog.csdn.net/qingchunqidewo/article/details/108861357