Skip to content

Instantly share code, notes, and snippets.

@StephenVinouze
Created May 12, 2020 16:21
Show Gist options
  • Save StephenVinouze/c0199b5154152a9f11f5581256551e17 to your computer and use it in GitHub Desktop.
Save StephenVinouze/c0199b5154152a9f11f5581256551e17 to your computer and use it in GitHub Desktop.
Ask audio permission
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.RECORD_AUDIO), RECORD_AUDIO_REQUEST_CODE)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment