Sonde Health API Platform Documentation
Android Enrollment Module
Overview
The following document is a guide for your app development. The below steps will provide you with detailed information for Enrollment of the user’s voice and saving it in shared preferences.
Import the following classes in your Activity/Fragment
import com.sondeservices.passive.enrollment.EnrollmentCallback
import sonde_passive.application_api.init.SondePassiveSdk
Before starting the Enrollment, add the next check to make sure that the
RECORD_AUDIO
permission is enabled in your app:Declare the following code.
private val REQUEST_CODE_RECORD_AUDIO = 11111
Then add the following check,
if (ContextCompat.checkSelfPermission(
requireContext(),
android.Manifest.permission.RECORD_AUDIO
) != PackageManager.PERMISSION_GRANTED
) {
val permissions = arrayOf(android.Manifest.permission.RECORD_AUDIO)
ActivityCompat.requestPermissions(
requireActivity(),
permissions,
REQUEST_CODE_RECORD_AUDIO
)
}
Also, verify that the app user grants record audio permission—the recording functionality will not function without permission. To do this, override the
onRequestPermissionsResult
method in your app and check the permission result.
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (requestCode == REQUEST_CODE_RECORD_AUDIO && grantResults.isNotEmpty()
&& grantResults[0] != PackageManager.PERMISSION_GRANTED) {
throw RuntimeException("Record Audio permission is required to start recording.")
}
}
Create
enrollmentHandler
and call thebeginEnrollment()
function to start Enrollment.
During enrollment, the following messages may be generated based on the enrollment audio analysis:
Background noise - The message will be generated if there is background noise in the first 20 seconds of the audio. The user must be informed, “High background noise detected; please move to a quieter location.”
Sonde Health