Skip to main content

Requesting Authorisation

When you are going to be accessing the microphone you must check that your application has been allowed access. To this end the extension provides several helpers to check and request access to the microphone and to the file system to save images.

On Android these permissions are listed through the manifest additions. On older versions of Android these permissions are accepted when the user installs the application. More modern versions (Marshmallow 6 [v23]+) require that you request the permissions similar to iOS. You will still need to list them in your manifest and then follow the same code below as for iOS, except that on Android you will be able to ask multiple times.

You should respect the SHOULD_EXPLAIN status by displaying additional information to your user about why you require this functionality.

AudioRecorder.service.addEventListener( AuthorisationEvent.CHANGED, authorisationStatus_changedHandler );

switch (AudioRecorder.service.authorisationStatus())
{
case AuthorisationStatus.SHOULD_EXPLAIN:
case AuthorisationStatus.NOT_DETERMINED:
// REQUEST ACCESS: This will display the permission dialog
AudioRecorder.service.requestAuthorisation();
return;

case AuthorisationStatus.DENIED:
case AuthorisationStatus.UNKNOWN:
case AuthorisationStatus.RESTRICTED:
// ACCESS DENIED: You should inform your user appropriately
return;

case AuthorisationStatus.AUTHORISED:
// AUTHORISED: Microphone will be available
break;
}

function authorisationStatus_changedHandler( event:AuthorisationEvent ):void
{
trace( "authorisationStatus_changedHandler: "+event.status );
}