Skip to content

[Bug]: intervalDuration not respected on Android 12 and below #1614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 of 8 tasks
motucraft opened this issue Dec 1, 2024 · 1 comment
Closed
3 of 8 tasks

[Bug]: intervalDuration not respected on Android 12 and below #1614

motucraft opened this issue Dec 1, 2024 · 1 comment
Assignees

Comments

@motucraft
Copy link

motucraft commented Dec 1, 2024

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Linux
  • macOS
  • Web
  • Windows

Steps to reproduce

  1. Clone the repository from this link.
  2. Run the application on a device or emulator with Android 12 or Android 13.
  3. Tap the "Determine Position" button. If prompted, grant location permissions to the app.
  4. Tap the "Start Tracking" button to start tracking your location.
  5. Observe the logs in the console for location updates.

Expected results

After tapping the "Start Tracking" button, location updates should be logged in the console at intervals of 10 seconds, as specified by the intervalDuration setting:

    final androidSettings = AndroidSettings(
      intervalDuration: Duration(seconds: 10),
    );

Actual results

  • On Android 13 (API 33)
    Location updates occur consistently at 10-second intervals, as specified by the intervalDuration setting:

    [log] 2024-12-01 21:30:04.494552 Position: 35.360625, 138.7273633
    [log] 2024-12-01 21:30:13.518845 Position: 35.360625, 138.7273633
    [log] 2024-12-01 21:30:22.528858 Position: 35.360625, 138.7273633
    [log] 2024-12-01 21:30:31.567809 Position: 35.360625, 138.7273633
    [log] 2024-12-01 21:30:40.578616 Position: 35.360625, 138.7273633
  • On Android 12 (API 32)
    Location updates occur at 5-second intervals, despite the intervalDuration being set to 10 seconds:

    [log] 2024-12-01 21:30:58.691525 Position: 35.360625, 138.7273633
    [log] 2024-12-01 21:31:02.696411 Position: 35.360625, 138.7273633
    [log] 2024-12-01 21:31:06.708068 Position: 35.360625, 138.7273633
    [log] 2024-12-01 21:31:10.723826 Position: 35.360625, 138.7273633
    [log] 2024-12-01 21:31:14.735681 Position: 35.360625, 138.7273633

This discrepancy suggests that the intervalDuration setting in the AndroidSettings is not being respected on Android 12, resulting in a default interval of 5 seconds instead of the configured 10 seconds.

Additional information

According to the API documentation for intervalDuration:

The desired interval for active location updates.
If this value is null an interval duration of 5000ms is applied.

There is no mention in the documentation that intervalDuration has limitations or behaves differently on Android 12 or lower. The observed behavior on Android 12 (updates occurring at 5-second intervals regardless of the setting) appears inconsistent with the documented behavior.

Code sample

The full reproducible sample can be found in the repository linked below. The main code for reproducing the issue is located in the main.dart file:

https://github.com/motucraft/issue_geolocator_intervel_duration/blob/master/lib/main.dart

To reproduce the issue, follow the steps outlined above.

Screenshots or video

No screenshots or videos are provided as the issue is fully described by the console logs and code sample above.

Version

13.0.2

Flutter Doctor output

Doctor output
% flutter doctor -v
[✓] Flutter (Channel stable, 3.24.5, on macOS 15.1.1 24B91 darwin-arm64, locale ja-JP)
    • Flutter version 3.24.5 on channel stable at /Users/osaki/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (3 weeks ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/osaki/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Users/osaki/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
    • Android Studio at /Users/osaki/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
    • IntelliJ at /Users/osaki/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 82.2.4
    • Dart plugin version 243.22562.3

[✓] VS Code (version 1.95.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.100.0

[✓] Connected device (6 available)
    • sdk gphone64 arm64 (mobile)     • emulator-5554             • android-arm64  • Android 13 (API 33) (emulator)
    • sdk gphone64 arm64 (mobile)     • emulator-5556             • android-arm64  • Android 12 (API 32) (emulator)
    • motucraft (mobile)              • 00008130-001A34290CC2001C • ios            • iOS 18.1.1 22B91
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 15.1.1 24B91 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 15.1.1 24B91 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 131.0.6778.86

[✓] Network resources
    • All expected network resources are available.

• No issues found!
@TimHoogstrate TimHoogstrate self-assigned this Dec 3, 2024
@TimHoogstrate
Copy link
Contributor

Dear @motucraft,

From the Android documentation: {https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.Builder#setIntervalMillis(long)}

Sets the desired interval of location updates. Location updates may arrive faster than this interval or slower than this interval (if the request is being throttled for example).

It does not seem something we can change. Try using a real device when testing. It may also be dependant on the desired accuracy. I'll close this issue for now. Feel free to reopen when needed.

Kind regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants