这里是对所以权限进行整体判断,单一判断的逻辑复杂,而且AlertDialog容易错乱(主要还是本人学艺不精~)
点击“始终允许”则打开权限不在提示;
点击“禁止”未选择“禁止不在询问”则循环请求循环(简单粗暴点吧);
点击“禁止”选择“禁止不在询问”则提示用户去应用手动打开权限。
以下是主类和权限基础类,算是简单进行封装吧
MainActivity.java
public class MainActivity extends PermissionBaseActivity {
private String[] mPermissions = new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.CAMERA,
Manifest.permission.ACCESS_COARSE_LOCATION};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setPermissions(mPermissions, new InterfacePermission() {
@Override
public void onAllow() {
Toast.makeText(MainActivity.this, "权限已全部允许,可进行初始化操作", Toast.LENGTH_SHORT).show();
}
});