Created
September 2, 2021 13:46
-
-
Save fatihkurcenli/0ab270ee1fd61fc87c1c70080f5af7e1 to your computer and use it in GitHub Desktop.
onRequestPermissionsResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
if (requestCode == CAMERA_PERMISSION_CODE) { | |
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
binding.btnCamera.setText("Permission granted"); | |
Toast.makeText(this, "Camera Permissions Granted", Toast.LENGTH_SHORT).show(); | |
} else { | |
Toast.makeText(this, "Camera Permissions Denied", Toast.LENGTH_SHORT).show(); | |
} | |
} else if (requestCode == READ_EXTERNAL_STORAGE_PERMISSION_CODE) { | |
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
binding.readPermissons.setText("Storage granted"); | |
Toast.makeText(this, "Storage Permissions Granted", Toast.LENGTH_SHORT).show(); | |
} else { | |
Toast.makeText(this, "Storage Permissions Denied", Toast.LENGTH_SHORT).show(); | |
} | |
} else if (requestCode == WRITE_EXTERNAL_STORAGE_PERMISSION_CODE) { | |
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
binding.writePermissions.setText("write storage granted"); | |
Toast.makeText(this, "Write Storage Permissions Granted", Toast.LENGTH_SHORT).show(); | |
} else { | |
Toast.makeText(this, "Write Storage Permissions Denied", Toast.LENGTH_SHORT).show(); | |
} | |
} else if (requestCode == ACCESS_FINE_LOCATION_PERMISSION_CODE) { | |
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
binding.accessFineLocation.setText("access location granted"); | |
Toast.makeText(this, "Access location Storage Permissions Granted", Toast.LENGTH_SHORT).show(); | |
} else { | |
Toast.makeText(this, "Access location Permissions Denied", Toast.LENGTH_SHORT).show(); | |
} | |
} else if (requestCode == FOREGROUND_SERVICE_PERMISSION_CODE) { | |
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
binding.accessFineLocation.setText("foreground service granted"); | |
Toast.makeText(this, "foreground service Storage Permissions Granted", Toast.LENGTH_SHORT).show(); | |
} else { | |
Toast.makeText(this, "foreground service Permissions Denied", Toast.LENGTH_SHORT).show(); | |
} | |
} else if (requestCode == ACCESS_BACKGROUND_SERVICE_PERMISSION_CODE) { | |
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
binding.bckaccessButton.setText("AccessBackground service granted"); | |
Toast.makeText(this, "AccessBackground service Storage Permissions Granted", Toast.LENGTH_SHORT).show(); | |
} else { | |
Toast.makeText(this, "AccessBackground service Permissions Denied", Toast.LENGTH_SHORT).show(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment