Java Code Examples for com.facebook.react.bridge.ReactApplicationContext#addLifecycleEventListener()

The following examples show how to use com.facebook.react.bridge.ReactApplicationContext#addLifecycleEventListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackgroundTimerModule.java    From react-native-background-timer with MIT License 7 votes vote down vote up
public BackgroundTimerModule(ReactApplicationContext reactContext) {
    super(reactContext);
    this.reactContext = reactContext;
    this.powerManager = (PowerManager) getReactApplicationContext().getSystemService(reactContext.POWER_SERVICE);
    this.wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "rohit_bg_wakelock");
    reactContext.addLifecycleEventListener(listener);
}
 
Example 2
Source File: UIManagerModule.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Deprecated
public UIManagerModule(
    ReactApplicationContext reactContext,
    ViewManagerResolver viewManagerResolver,
    UIImplementationProvider uiImplementationProvider,
    int minTimeLeftInFrameForNonBatchedOperationMs) {
  super(reactContext);
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext);
  mEventDispatcher = new EventDispatcher(reactContext);
  mModuleConstants = createConstants(viewManagerResolver);
  mCustomDirectEvents = UIManagerModuleConstants.getDirectEventTypeConstants();
  mUIImplementation =
      uiImplementationProvider.createUIImplementation(
          reactContext,
          viewManagerResolver,
          mEventDispatcher,
          minTimeLeftInFrameForNonBatchedOperationMs);

  reactContext.addLifecycleEventListener(this);
}
 
Example 3
Source File: RNBluetoothManagerModule.java    From react-native-bluetooth-status with MIT License 5 votes vote down vote up
public RNBluetoothManagerModule(ReactApplicationContext reactContext) {
    super(reactContext);
    this.reactContext = reactContext;
    reactContext.addLifecycleEventListener(this);
    btAdapter = BluetoothAdapter.getDefaultAdapter();
    registerBroadcastReceiver();
}
 
Example 4
Source File: GoogleCastModule.java    From react-native-google-cast with MIT License 5 votes vote down vote up
public GoogleCastModule(ReactApplicationContext reactContext) {
    super(reactContext);
    if (CAST_AVAILABLE) {
        reactContext.addLifecycleEventListener(this);
        setupCastListener();
    }
}
 
Example 5
Source File: MagnetScannerReact.java    From magnet-client with Mozilla Public License 2.0 5 votes vote down vote up
MagnetScannerReact(ReactApplicationContext context) {
    super(context);
    mContext = context;

    context.addLifecycleEventListener(this);
    context.addActivityEventListener(this);

    mPermissionChecker = new PermissionChecker();
    mMagnetScanner = new MagnetScanner(context)
            .useBle()
            .useGeolocation();
}
 
Example 6
Source File: TwilioVoiceModule.java    From react-native-twilio-programmable-voice with MIT License 5 votes vote down vote up
public TwilioVoiceModule(ReactApplicationContext reactContext,
boolean shouldAskForMicPermission) {
    super(reactContext);
    if (BuildConfig.DEBUG) {
        Voice.setLogLevel(LogLevel.DEBUG);
    } else {
        Voice.setLogLevel(LogLevel.ERROR);
    }
    reactContext.addActivityEventListener(this);
    reactContext.addLifecycleEventListener(this);

    eventManager = new EventManager(reactContext);
    callNotificationManager = new CallNotificationManager();
    proximityManager = new ProximityManager(reactContext, eventManager);
    headsetManager = new HeadsetManager(eventManager);

    notificationManager = (android.app.NotificationManager) reactContext.getSystemService(Context.NOTIFICATION_SERVICE);

    /*
     * Setup the broadcast receiver to be notified of GCM Token updates
     * or incoming call messages in this Activity.
     */
    voiceBroadcastReceiver = new VoiceBroadcastReceiver();
    registerReceiver();

    TwilioVoiceModule.callNotificationMap = new HashMap<>();

    /*
     * Needed for setting/abandoning audio focus during a call
     */
    audioManager = (AudioManager) reactContext.getSystemService(Context.AUDIO_SERVICE);

    /*
     * Ensure the microphone permission is enabled
     */
    if (shouldAskForMicPermission && !checkPermissionForMicrophone()) {
        requestPermissionForMicrophone();
    }
}
 
Example 7
Source File: ReactNativeNotificationHubModule.java    From react-native-azurenotificationhub with MIT License 5 votes vote down vote up
public ReactNativeNotificationHubModule(ReactApplicationContext reactContext) {
    super(reactContext);
    this.mReactContext = reactContext;
    this.mLocalBroadcastReceiver = new LocalBroadcastReceiver();
    LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(reactContext);
    localBroadcastManager.registerReceiver(mLocalBroadcastReceiver, new IntentFilter(ReactNativeRegistrationIntentService.TAG));
    localBroadcastManager.registerReceiver(mLocalBroadcastReceiver, new IntentFilter(ReactNativeNotificationsHandler.TAG));
    reactContext.addLifecycleEventListener(this);
    reactContext.addActivityEventListener(this);
}
 
Example 8
Source File: RNKakaoLoginsModule.java    From react-native-kakao-login with MIT License 5 votes vote down vote up
public RNKakaoLoginsModule(ReactApplicationContext reactContext) {
    super(reactContext);
    this.reactContext = reactContext;
    if (KakaoSDK.getAdapter() == null) {
        KakaoSDK.init(new KakaoSDKAdapter(reactContext.getApplicationContext()));
    } else {
        Session.getCurrentSession().clearCallbacks();
    }
    reactContext.addActivityEventListener(this);
    reactContext.addLifecycleEventListener(this);
    callback = new SessionCallback();
    Session.getCurrentSession().addCallback(callback);
    Session.getCurrentSession().checkAndImplicitOpen();
}
 
Example 9
Source File: WearCommunicationModule.java    From react-native-android-wear-demo with MIT License 5 votes vote down vote up
public WearCommunicationModule(ReactApplicationContext reactContext) {
  super(reactContext);
  reactContext.addLifecycleEventListener(this);
  googleApiClient = new GoogleApiClient.Builder(getReactApplicationContext()).addApi(Wearable.API)
    .addConnectionCallbacks(this)
    .build();
}
 
Example 10
Source File: RNCAppearanceModule.java    From react-native-appearance with MIT License 5 votes vote down vote up
public RNCAppearanceModule(@NonNull ReactApplicationContext reactContext) {
    super(reactContext);
    // Only Android 10+ supports dark mode
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
        final ReactApplicationContext ctx = reactContext;
        mBroadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                Configuration newConfig = intent.getParcelableExtra("newConfig");
                sendEvent(ctx, "appearanceChanged", getPreferences());
            }
        };
        ctx.addLifecycleEventListener(this);
    }
}
 
Example 11
Source File: UploaderModule.java    From react-native-background-upload with MIT License 5 votes vote down vote up
public UploaderModule(ReactApplicationContext reactContext) {
  super(reactContext);

  this.reactContext = reactContext;
  reactContext.addLifecycleEventListener(this);

  if (uploadReceiver == null) {
    uploadReceiver = new UploadReceiver();
    uploadReceiver.register(reactContext);
  }

  UploadService.NAMESPACE = reactContext.getApplicationInfo().packageName;
  UploadService.HTTP_STACK = new OkHttpStack();
}
 
Example 12
Source File: RNSensorsDataModule.java    From react-native-sensors-analytics with Apache License 2.0 5 votes vote down vote up
public RNSensorsDataModule(ReactApplicationContext reactContext) {
    super(reactContext);
    try{
        reactContext.addLifecycleEventListener(new SensorsDataLifecycleListener());
    }catch(Exception e){

    }
    RNAgent.ignoreView();
}
 
Example 13
Source File: NativeAnimatedModule.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public void initialize() {
  ReactApplicationContext reactCtx = getReactApplicationContext();
  UIManagerModule uiManager = reactCtx.getNativeModule(UIManagerModule.class);
  reactCtx.addLifecycleEventListener(this);
  uiManager.addUIManagerListener(this);
}
 
Example 14
Source File: BackgroundGeolocationModule.java    From react-native-background-geolocation with Apache License 2.0 5 votes vote down vote up
public BackgroundGeolocationModule(ReactApplicationContext reactContext) {
    super(reactContext);
    reactContext.addLifecycleEventListener(this);

    facade = new BackgroundGeolocationFacade(getContext(), this);
    logger = LoggerManager.getLogger(BackgroundGeolocationModule.class);
}
 
Example 15
Source File: RNDataWedgeIntentsModule.java    From react-native-datawedge-intents with MIT License 5 votes vote down vote up
public RNDataWedgeIntentsModule(ReactApplicationContext reactContext) {
  super(reactContext);
  this.reactContext = reactContext;
  reactContext.addLifecycleEventListener(this);
  Log.v(TAG, "Constructing React native DataWedge intents module");

  //  Register a broadcast receiver to return data back to the application
  ObservableObject.getInstance().addObserver(this);
}
 
Example 16
Source File: HotspotModule.java    From react-native-wifi-hotspot with ISC License 4 votes vote down vote up
public HotspotModule(ReactApplicationContext reactContext) {
    super(reactContext);
    reactContext.addLifecycleEventListener(this);
    hotspot = new HotspotManager(reactContext);
}
 
Example 17
Source File: WorkerModule.java    From react-native-workers with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public WorkerModule(final ReactApplicationContext reactContext, ReactPackage additionalWorkerPackages[]) {
    super(reactContext);
    workers = new HashMap<>();
    this.additionalWorkerPackages = additionalWorkerPackages;
    reactContext.addLifecycleEventListener(this);
}
 
Example 18
Source File: UnityViewManager.java    From react-native-unity-view with MIT License 4 votes vote down vote up
UnityViewManager(ReactApplicationContext context) {
    super();
    this.context = context;
    context.addLifecycleEventListener(this);
}
 
Example 19
Source File: RCTChirpSDKModule.java    From chirp-react-native with Apache License 2.0 4 votes vote down vote up
public RCTChirpSDKModule(ReactApplicationContext reactContext) {
    super(reactContext);
    context = reactContext;
    reactContext.addLifecycleEventListener(this);
}
 
Example 20
Source File: RNFirebaseCrashReportModule.java    From react-native-firebase-crash-report with ISC License 4 votes vote down vote up
public RNFirebaseCrashReportModule(ReactApplicationContext reactContext) {
    super(reactContext);
    reactContext.addLifecycleEventListener(this);
}