Manual Selfie Capture
This module includes a Fragment that allows the user take a selfie with a click of a button. The difference from the Auto Selfie is just there is no button in Auto Selfie as the selfie is taken automatically on AutoSelfie.
Starting the Selfie capture
Add the imports below:
import ai.amani.sdk.Amani
import ai.amani.sdk.interfaces.IFragmentCallBack
import android.graphics.Bitmap
import java.io.File
Then start the manual selfie capture and get its Fragment as shown below:
// Getting the Fragment view of Selfie
val fragment = Amani.sharedInstance()
.Selfie()
.start(
"XXX_SE_0",
object : IFragmentCallBack {
override fun cb(bitmap: Bitmap?, manualButtonActivated: Boolean?, file: File?) {
// If bitmap is not null, selfie is taken successfully.
// The upload function can be called.
}
}
)
// Navigating to the fragment view
fragment?.let {
replaceFragmentWithBackStack(R.id.frame_manual_selfie, it)
}
Uploading the Captured Selfie
note
The upload method has to be called after the result of the start method is successful.
Otherwise you'll encounter an error in the Errors() object when called.
Add the imports below:
import ai.amani.sdk.Amani
Then upload the captured selfie as shown below:
//Uploading the current taken Selfie data
Amani.sharedInstance()
.Selfie()
.upload(
requireContext(),
"XXX_SE_0"
) { isSuccess ->
if (isSuccess) {
Log.i(TAG, "Selfie is uploaded")
} else {
Log.e(TAG, "Selfie could not be uploaded")
}
}