Firebase GET_ACCOUNTS权限崩溃

时间:2017-12-05 17:55:20

标签: android firebase manifest

在我的firebase崩溃报告中告诉我“缺少权限get_account”

我的清单文件中有get_account,这是我在运行时向用户请求的代码

  

SplashActivity.class

   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(SplashActivity.this.getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(SplashActivity.this.getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            final Dialog dialog = new Dialog(this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(false);
            LayoutInflater lf = (LayoutInflater) this
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View dialogview = lf.inflate(R.layout.access_permission_dialog, null);
            Button ok_btn = (Button) dialogview.findViewById(R.id.ok_btn);
            Button cancel_btn = (Button) dialogview.findViewById(R.id.cancel_btn);
            ok_btn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    flag = 1;
                    dialog.dismiss();
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                        requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION
                                , Manifest.permission.ACCESS_COARSE_LOCATION
                                , Manifest.permission.WRITE_EXTERNAL_STORAGE
                                , Manifest.permission.READ_EXTERNAL_STORAGE
                                , Manifest.permission.READ_CALENDAR
                                , Manifest.permission.GET_ACCOUNTS
                                , Manifest.permission.READ_CONTACTS

                        }, AppConstants.MY_APP_PERMISSIONS);


                    }

知道它为什么会一直崩溃吗?

1 个答案:

答案 0 :(得分:0)

解决了我添加此问题的问题

ContextCompat.checkSelfPermission(SplashActivity.this.getApplicationContext(), Manifest.permission.GET_ACCOUNTS)

此权限位于“联系人”下,正如此文档所述

Android Permissions