Let's say, I have a MediaRecorder class that I will be using in a different fragment which looks this way:
class Recorder @Inject constructor(
lifecycle: Lifecycle,
private val mediaRecorder: MediaRecorder
) : LifecycleObserver {
init {
lifecycle.addObserver(this)
}
fun startRecording() {
mediaRecorder.prepare()
mediaRecorder.start()
}
fun stopRecording() {
mediaRecorder.stop()
mediaRecorder.release()
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
fun onPauseEvent() {
mediaRecorder.pause()
}
}
I want to inject here the lifecycle of the fragment/activity that I will be using here.
How can I do that?