Android marshmallow request permission?

后端 未结 24 2090
無奈伤痛
無奈伤痛 2020-11-21 06:40

I am currently working on an application that requires several \"dangerous\" permissions. So I tried adding \"ask for permission\" as required in Android Marshmallow(API Lev

24条回答
  •  情歌与酒
    2020-11-21 07:29

      if (CommonMethod.isNetworkAvailable(MainActivity.this)) {
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                            int permissionCheck = ContextCompat.checkSelfPermission(MainActivity.this,
                                    android.Manifest.permission.CAMERA);
                            if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
                                //showing dialog to select image
                                callFacebook();
                                Log.e("permission", "granted MarshMallow");
                            } else {
                                ActivityCompat.requestPermissions(MainActivity.this,
                                        new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE,
                                                android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.CAMERA}, 1);
                            }
                        } else {
                            Log.e("permission", "Not Required Less than MarshMallow Version");
                            callFacebook();
                        }
                    } else {
                        CommonMethod.showAlert("Internet Connectivity Failure", MainActivity.this);
                    }
    

提交回复
热议问题