Skip to main content

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​

// 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.

//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 uploaded")
}
}