如何在此弹出窗口中删除“永不再问”字样?

时间:2017-11-15 12:58:00

标签: android android-permissions permission-denied

如何在没有“永不再问”文字的情况下请求权限弹出窗口?

这里是java Code,

    if 
 (intent.getAction().equals("com.finish.canceltrip.DriverMapActivity")) {
                if (!checkAccessFineLocationPermission() || !checkAccessCoarseLocationPermission() || !checkWriteExternalStoragePermission()) {
                    requestPermission();
                } else {
                    Intent i = new Intent(DriverMapActivity.this, DriverMapActivity.class);
                    i.putExtra("availability", "Yes");
                    finish();
                    startActivity(i);

                }

enter image description here

2 个答案:

答案 0 :(得分:6)

  

如何在没有“永不再问”文字的情况下请求权限弹出窗口?

否您无法从权限对话框中删除“永不再问”

如果用户选择从不再询问

,请尝试此操作

请求这样的许可

 btnCurrentLocationSearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String permission = android.Manifest.permission.ACCESS_FINE_LOCATION;


                if (ActivityCompat.checkSelfPermission(SearchCityClass.this, permission)
                        != PackageManager.PERMISSION_GRANTED && ActivityCompat.
                        checkSelfPermission(SearchCityClass.this, android.Manifest.permission.ACCESS_COARSE_LOCATION)
                        != PackageManager.PERMISSION_GRANTED) {

                    Toast.makeText(SearchCityClass.this, "Permission not granted", Toast.LENGTH_SHORT).show();

                    ActivityCompat.requestPermissions(SearchCityClass.this, new String[]
                            {permission}, requestCode);

                } else {
                    isPermissionGranted(true);
                }
            }

        });

处理 onRequestPermissionsResult

中的权限结果
    @Override
        public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
            super.onRequestPermissionsResult(requestCode, permissions, grantResults);
            if (requestCode == requestCode) {
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                    isPermissionGranted(true);
                } else {

                    isPermissionGranted(false);
                }
            }
        }

而不是创建像这样的方法

public void isPermissionGranted(boolean permission) {
        if (!permission) {
            Toast.makeText(this, "Permission not Granted", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                    Uri.fromParts("package", getPackageName(), null)));
        } else {
            Toast.makeText(SearchCityClass.this, "true", Toast.LENGTH_SHORT).show();
            Toast.makeText(SearchCityClass.this, "Permission granted", Toast.LENGTH_SHORT).show();
            // you need to perform all action here if user grants the permission
        }
    }

答案 1 :(得分:1)

不,你无法从该对话框中删除从不再询问

如果用户再次拒绝该应用应该在完全需要该权限时关闭,或者继续以有限的功能运行。

如果用户重新考虑(并选择重试),则再次请求权限。这次提示符如下所示: