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

Audio recording and permissions in Marshmallow #17

@janekp

Description

@janekp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions