How to handle background mode on open modal

Hello,
I am developing a geolocation application which should record the position and send it even when it is in the background.
I use the modules

@ionic-native/background-mode

and

@ionic-native/background-geolocation

Everything seems to be working properly but when I open a modal or use the camera the background is automatically activated.

Is there any way to handle this behavior?

thanks in advance
maurizio

Are you using iOS or android? When you say modal, are you using Ionic’s modals or a native plugin?

If your ussing android and opening a camera, this is technically correct. As android treats this as different activities and processes. So opening the camera calls the camera app, vs overlaying a camera view within the main app.

I’d see if there are different event details here that you could inspect, or wait before actually calling any utils in the background process.

thanks for reply
I use ionic-angular modal and the behavior seems present only in Android.
I have the same problem wih system modal for permission request.

I tried to block my background operations when I open modals or request system permissions but I’m a little confused by the behavior of the app.

disabling background mode during open modals o camera, files chooser, etc… with:

this.backgroundMode.setEnabled(false);

and re-enabling it at the end of the procedure with:

this.backgroundMode.enable();

may be a correct procedure?

I can’t understand the background mode behavior…
I initialize the background mode with this code:

  backgroundServiceInit(): boolean {
    //BACKGROUND MODE
    let self=this;
    try {
      //self.backgroundMode.enable();
      self.backgroundMode.setDefaults({ silent: false });
      self.backgroundMode.overrideBackButton();
      self.backgroundMode.disable();

      this.backgroundMode.on('activate').subscribe(() => {
          self.logProvider.handleLog('log', 'debug', 'AppStatusProvider backgroundMode.on(activate)!!!');
          self.backgroundMode.disableWebViewOptimizations();
          self.backgroundMode.disableBatteryOptimizations();
          //self.backgroundMode.excludeFromTaskList();
      });

      this.backgroundMode.on('deactivate').subscribe(() => {
        self.logProvider.handleLog('log', 'debug', 'AppStatusProvider backgroundMode.on(deactivate)!!!');
        self.backgroundMode.moveToForeground();
      });

      this.backgroundMode.on('failure').subscribe(() => {
        self.logProvider.handleLog('log', 'debug', 'AppStatusProvider backgroundMode.on(failure)!!!');
      });

      self.platform.pause.subscribe(() => {
        //self.backgroundMode.moveToBackground();
      });
      return true;

    } catch (e) {
      this.logProvider.handleLog('log','debug','AppStatusProvider backgroundServiceInit ERROR', e.message);
      return false;
    }
  }

it’s should be disabled but when the camera app is open the activate event is generated.

wat’s is wrong?