@ReactMethod
public void initialize() {
ReactApplication application = (ReactApplication)getReactApplicationContext()
.getCurrentActivity()
.getApplication();
DevSupportManager devSupportManager = application
.getReactNativeHost()
.getReactInstanceManager()
.getDevSupportManager();
devSupportManager.addCustomDevOption("Log AsyncStorage", new DevOptionHandler() {
@Override
public void onOptionSelected() {
getReactApplicationContext()
.getJSModule(RCTNativeAppEventEmitter.class)
.emit("LogAsyncStorage", null);
}
});
}
java类com.facebook.react.ReactApplication的实例源码
AsyncStorageDevMenuItemModule.java 文件源码
项目:react-native-async-storage-dev-menu-item
阅读 26
收藏 0
点赞 0
评论 0
ReactNativeRestart.java 文件源码
项目:react-native-restart
阅读 28
收藏 0
点赞 0
评论 0
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException {
ReactInstanceManager instanceManager = getReactInstanceManager();
if (instanceManager != null) {
return instanceManager;
}
final Activity currentActivity = getCurrentActivity();
if (currentActivity == null) {
return null;
}
ReactApplication reactApplication = (ReactApplication) currentActivity.getApplication();
instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager();
return instanceManager;
}
DevSettingsModule.java 文件源码
项目:react-native-devsettings-android
阅读 32
收藏 0
点赞 0
评论 0
public DevSettingsModule(ReactApplicationContext context) {
super(context);
reactContext = context;
rnHost = ((ReactApplication) context.getApplicationContext())
.getReactNativeHost();
instanceManager = rnHost.getReactInstanceManager();
useDeveloperSupport = rnHost.getUseDeveloperSupport();
if (useDeveloperSupport) {
devManager = ((DevSupportManagerImpl) instanceManager.getDevSupportManager());
}
}
ReactNativeEventStarter.java 文件源码
项目:react-native-background-job
阅读 30
收藏 0
点赞 0
评论 0
@Nullable @Override protected HeadlessJsTaskConfig getTaskConfig(Intent intent) {
Log.d(LOG_TAG, "getTaskConfig() called with: intent = [" + intent + "]");
Bundle extras = intent.getExtras();
boolean allowExecutionInForeground = extras.getBoolean("allowExecutionInForeground", false);
long timeout = extras.getLong("timeout", 2000);
// For task with quick execution period additional check is required
ReactNativeHost reactNativeHost =
((ReactApplication) getApplicationContext()).getReactNativeHost();
boolean appInForeground = Utils.isReactNativeAppInForeground(reactNativeHost);
if (appInForeground && !allowExecutionInForeground) {
return null;
}
return new HeadlessJsTaskConfig(intent.getStringExtra("jobKey"), Arguments.fromBundle(extras),
timeout, allowExecutionInForeground);
}
RNSentryModule.java 文件源码
项目:react-native-sentry
阅读 22
收藏 0
点赞 0
评论 0
public RNSentryModule(ReactApplicationContext reactContext, ReactApplication reactApplication) {
super(reactContext);
this.reactContext = reactContext;
this.reactApplication = reactApplication;
RNSentryModule.extra = new WritableNativeMap();
RNSentryModule.packageInfo = getPackageInfo(reactContext);
}
ReactPreLoader.java 文件源码
项目:react-native-preloader
阅读 27
收藏 0
点赞 0
评论 0
/**
* Pre-load {@link ReactRootView} to local {@link Map}, you may want to
* load it in previous activity.
*/
public static void init(Activity activity, ReactInfo reactInfo) {
if (CACHE_VIEW_MAP.get(reactInfo.getMainComponentName()) != null) {
return;
}
ReactRootView rootView = new ReactRootView(new MutableContextWrapper(activity));
rootView.startReactApplication(
((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(),
reactInfo.getMainComponentName(),
reactInfo.getLaunchOptions());
CACHE_VIEW_MAP.put(reactInfo.getMainComponentName(), rootView);
}
GcmToken.java 文件源码
项目:react-native-notifications
阅读 22
收藏 0
点赞 0
评论 0
protected void sendTokenToJS() {
final ReactInstanceManager instanceManager = ((ReactApplication) mAppContext).getReactNativeHost().getReactInstanceManager();
final ReactContext reactContext = instanceManager.getCurrentReactContext();
// Note: Cannot assume react-context exists cause this is an async dispatched service.
if (reactContext != null && reactContext.hasActiveCatalystInstance()) {
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(TOKEN_RECEIVED_EVENT_NAME, sToken);
}
}
RCTUpdate.java 文件源码
项目:react-native-update
阅读 25
收藏 0
点赞 0
评论 0
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException {
ReactInstanceManager instanceManager;
final Activity currentActivity = getCurrentActivity();
if (currentActivity == null) {
return null;
}
ReactApplication reactApplication = (ReactApplication) currentActivity.getApplication();
instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager();
return instanceManager;
}
WorkerModule.java 文件源码
项目:react-native-workers
阅读 69
收藏 0
点赞 0
评论 0
private ReactInstanceManager getReactInstanceManager() {
ReactApplication reactApplication = (ReactApplication)getCurrentActivity().getApplication();
return reactApplication.getReactNativeHost().getReactInstanceManager();
}
ReactNativeEventStarter.java 文件源码
项目:react-native-background-job
阅读 29
收藏 0
点赞 0
评论 0
ReactNativeEventStarter(@NonNull Context context) {
this.context = context;
reactNativeHost = ((ReactApplication) context.getApplicationContext()).getReactNativeHost();
}
RNSentryPackage.java 文件源码
项目:react-native-sentry
阅读 24
收藏 0
点赞 0
评论 0
public RNSentryPackage(ReactApplication reactApplication) {
this.reactApplication = reactApplication;
}
RNSentryPackage.java 文件源码
项目:react-native-sentry
阅读 25
收藏 0
点赞 0
评论 0
public ReactApplication getReactApplication() {
return reactApplication;
}
RNSentryModule.java 文件源码
项目:react-native-sentry
阅读 24
收藏 0
点赞 0
评论 0
public ReactApplication getReactApplication() {
return reactApplication;
}
GcmToken.java 文件源码
项目:react-native-notifications
阅读 22
收藏 0
点赞 0
评论 0
protected GcmToken(Context appContext) {
if (!(appContext instanceof ReactApplication)) {
throw new IllegalStateException("Application instance isn't a react-application");
}
mAppContext = appContext;
}
ReactFragment.java 文件源码
项目:react-native-android-fragment
阅读 23
收藏 0
点赞 0
评论 0
/**
* Get the {@link ReactNativeHost} used by this app. By default, assumes
* {@link Activity#getApplication()} is an instance of {@link ReactApplication} and calls
* {@link ReactApplication#getReactNativeHost()}. Override this method if your application class
* does not implement {@code ReactApplication} or you simply have a different mechanism for
* storing a {@code ReactNativeHost}, e.g. as a static field somewhere.
*/
protected ReactNativeHost getReactNativeHost() {
return ((ReactApplication) getActivity().getApplication()).getReactNativeHost();
}
MrReactActivity.java 文件源码
项目:react-native-preloader
阅读 23
收藏 0
点赞 0
评论 0
/**
* Get the {@link ReactNativeHost} used by this app. By default, assumes {@link #getApplication()}
* is an instance of {@link ReactApplication} and calls
* {@link ReactApplication#getReactNativeHost()}. Override this method if your application class
* does not implement {@code ReactApplication} or you simply have a different mechanism for
* storing a {@code ReactNativeHost}, e.g. as a static field somewhere.
*/
protected ReactNativeHost getReactNativeHost() {
return ((ReactApplication) getApplication()).getReactNativeHost();
}