Android笔记之权限库AndPermission

GitHub地址:https://github.com/yanzhenjie/AndPermission

这个库可以节省不少代码量和时间

使用示例如下

        findViewById(R.id.btnGetLocation).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AndPermission.with(HomeActivity.this).runtime().permission(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
                        .onGranted(new Action>() {
                            @Override
                            public void onAction(List permissions) {
                                Log.d(TAG, "onAction(List) called in onGranted, permissions: " + permissions);
                            }
                        })
                        .onDenied(new Action>() {
                            @Override
                            public void onAction(List data) {
                                Log.d(TAG, "onAction(List) called in onDenied, data: " + data);
                            }
                        }).start();
            }
        });

 

转载于:https://www.cnblogs.com/buyishi/p/10556916.html

你可能感兴趣的:(Android笔记之权限库AndPermission)