How to access currentActivity and lifecycleowner in Fabric Module? #63
Unanswered
BraveEvidence
asked this question in
Q&A
Replies: 1 comment
-
Should I pass
Is this correct? I am worried about memory leak |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to create a
Fabric
module.The code is something like this. I am using
camera-x
lib which requires access tolifecycleowner
and for some bluetooth permissions I requirecurrentActivity
as well.So in
bindToLifecycle
, this refers tolifecycleowner
In old architecture we would get
lifecycleowner
using below codebut in the new architecture we can't cast
Context
toReactContext
as that throws errorAlso there is no way to access
currentActivity
in aFabric
module as theconstructor
takesContext
and not aReactApplicationContext
. PassingReactApplicationContext
instead ofContext
throws error as theViewManager
class requiresThemedReactContext
which is kind of similar toContext
as there is no way to getcurrentActivity
orlifecycle
fromThemedReactContext
I am using this approach to create a fabric module
Beta Was this translation helpful? Give feedback.
All reactions