-6

How can I request the permission popup without “Never ask again” text?

Here 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

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
Ana
  • 174
  • 1
  • 2
  • 10

2 Answers2

7

How can I request the permission popup without “Never ask again” text?

NO you can not remove “Never ask again” from Permission Dialog

try this this hack if user selects Never ask again

ask for permission like this

 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);
                }
            }

        });

than handle permission result in 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);
                }
            }
        }

than create a method like this

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
        }
    }
Goku
  • 9,102
  • 8
  • 50
  • 81
1

No u can not remove Never ask again from that dialog

If the user declines again the app should either shut down if it absolutely needs that permission or keep running with limited functionality.

If the user reconsiders (and selects re-try), the permission is requested again. This time the prompt looks like this:

ND1010_
  • 3,743
  • 24
  • 41