Skip to content
This repository has been archived by the owner on Jul 31, 2019. It is now read-only.

Audio recording and permissions in Marshmallow #17

Open
janekp opened this issue May 3, 2016 · 1 comment
Open

Audio recording and permissions in Marshmallow #17

janekp opened this issue May 3, 2016 · 1 comment

Comments

@janekp
Copy link

janekp commented May 3, 2016

Users must explicitly give their permission inside the application to use the microphone in Android 6.0 and later. And these permission checks should happen as late as possible so the user can understand the purpose. However, these use-cases are not handled in the library.

Specifically:

  • User hasn't used the microphone yet (push-to-send mode)
  • User has disabled the microphone permission in System settings

Right now Jumble will simply fail with an exception. No input or output audio. I did a quick test and added additional checks to the AudioHandler.java class along with an additional method to start recording later (triggered after the user has granted the permission). Seems to work. Not sure about side-effects.

private boolean canRecordAudio() {
        return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(mContext, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) ? false : true;
    }

// Usage sample
if(canRecordAudio()) {
            mInput = new AudioInput(this, mAudioSource, mSampleRate);
        } else {
            mInput = null;
        }
// Additional checks later
@pjgranahan
Copy link

+1, I ran into this today.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants