Alberto Dallaporta Alberto Dallaporta - 1 year ago 263
Android Question

ReactNative - How to get activity instance starting from version 0.29

I am writing my own ViewManager which does need to get activity instance. Before version 0.29 it was straight forward, but after RN@0.29 breaking changes I can't find a way to do it.

Thank you.

Answer Source

Next React Native version will have the reactContext.getCurrentActivity() method exposed publicly rather than just being available when extending ReactContextBaseJavaModule.

Relevant commit:

Update: I've just confirmed that this change will be cherry-picked into 0.31 and will land in few days.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download