Closed
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
Description
Is this a bug report?
Yes?
Have you read the Bugs section of the Contributing to React Native Guide?
yes
Environment
react-native-cli: 2.0.1
react-native: 0.44.2
v7.10.0
5.1.0
Android
macOS
Android Studio
Steps to Reproduce
Create a Native Module to save data:
FileOutputStream fos = getReactApplicationContext().openFileOutput(MainApplication.SOME_DATA_FILE, Context.MODE_PRIVATE);
I'm trying to provide a static method to retrieve the data inside SOME_DATA_FILE
Expected Behavior
I don't know if it's possible to cast ApplicationContext to ReactApplicationContext
...Module(ReactApplicationContext reactContext) { ...
Actual Behavior
Since getReactApplicationContext is not static, I have to instantiate the Module.
Naively doing so from Android code gives me an error:
(casting etc, does not work)
DataModule dm = new DataModule((ReactApplicationContext) getApplicationContext());
dm.getData();
Reproducible Demo
Metadata
Metadata
Assignees
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
Activity
hramos commentedon Jul 10, 2017
This issue looks like a question that would be best asked on StackOverflow.
StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.
Will close this as this is really a question that should be asked on StackOverflow.