Created
September 28, 2018 17:17
-
-
Save felipebelluco/12ebe4114fb2c8cf870c0e0b5ac11f36 to your computer and use it in GitHub Desktop.
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 fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { | |
when (requestCode) { | |
CALL_PHONE_RESULT_CODE -> { | |
if (grantResults.isNotEmpty() && grantResults.first() == PackageManager.PERMISSION_GRANTED) { | |
// Permissão foi concedida, já é possível usufruir da funcionalidade | |
} else if (!shouldShowRequestPermissionRationale(Manifest.permission.CALL_PHONE)) { | |
// Usuário marcou a caixa "não perguntar novamente" | |
// Mostrar uma dialog explicando a importância do app ter acesso a funcionalidade | |
} else { | |
// Usuário negou acesso à permissão | |
// Bloquear trecho que utilizava a funcionalidade ou informar o usuário da necessidade de ter acesso à funcionalidade | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment