flutter_background_geolocation icon indicating copy to clipboard operation
flutter_background_geolocation copied to clipboard

[Bug]: The app stops tracking if the phone has 'Remove permissions if app isn't used' enabled. most of the phones have that feature as enabled by default.

Open reev-create opened this issue 7 months ago • 5 comments

Required Reading

  • [x] Confirmed

Plugin Version

4.16.9

Flutter Doctor

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.4, on macOS 15.3.1 24D70 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.100.1)
[✓] VS Code (version 1.101.0-insider)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

Mobile operating-system(s)

  • [ ] iOS
  • [x] Android

Device Manufacturer(s) and Model(s)

vivo y72 5G

Device operating-systems(s)

Android 13

What happened?

Dear Sir/Madam,

Most of the devices have this feature as default. and hence the app stops tracking once killed from background.

Plugin Code and/or Config

bg.BackgroundGeolocation.onMotionChange((bg.Location location) {
      log('[motionchange] - ${location}');
    });

    // Fired whenever the state of location-services changes.  Always fired at boot
    bg.BackgroundGeolocation.onProviderChange((bg.ProviderChangeEvent event) {
      log('[providerchange] - $event');
    });

    bg.BackgroundGeolocation.registerHeadlessTask(
        backgroundGeolocationHeadlessTask);

    bg.Config bgConfig = bg.Config(
        desiredAccuracy: bg.Config.DESIRED_ACCURACY_MEDIUM,
        stopOnTerminate: false,
        startOnBoot: true,
        preventSuspend: true,
        debug: false,
        enableHeadless: true,
        autoSync: true,
        batchSync: true,
        allowIdenticalLocations: true,
        disableAutoSyncOnCellular: false,
        notification: new bg.Notification(
            title: "myHisaab",
            text: "Your location is being tracked during the punched phase"),
        notificationTitle: 'myHisaab',
        notificationText:
            'Your location is being tracked during the punched phase',
        foregroundService: true,
        showsBackgroundLocationIndicator: true,
        forceReloadOnBoot: true,
        url:"$SERVER_URL_STRING",
        logLevel: bg.Config.LOG_LEVEL_OFF);
    await bg.BackgroundGeolocation.ready(bgConfig).then((bg.State state) async {
      print('[ready] BackgroundGeolocation is configured and ready to use');
      await bg.BackgroundGeolocation.start();
      bg.BackgroundGeolocation.sync();
      return;
    });

Relevant log output


reev-create avatar May 16 '25 05:05 reev-create

The app tracks for sometime but then stops. after 5-10 minutes.

reev-create avatar May 16 '25 08:05 reev-create

What would you expect the plug-in to do I this case?

christocracy avatar May 16 '25 09:05 christocracy

Alright so, i'm not sure what happened but i disabled the ''Remove permissions if app isn't used'. it has to do something with the device and the plugin. because in the normal work manager, it's working. but using this package it is not. PLease look into it and fix it.

reev-create avatar May 16 '25 09:05 reev-create

What exactly are you expecting the plug-in to do with respect to the system setting “Remove permissions if app isn't used”?

christocracy avatar May 16 '25 09:05 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jun 16 '25 02:06 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jun 30 '25 02:06 github-actions[bot]