Open RabbitQuestBV opened 4 months ago
Hey, we have the same issue with the same model, Pixel 6a.
We assume that the problem is caused by the absence of the sticky notification for location tracking. After the user accepts the notification permission, all notification channels are activated in the system settings EXCEPT the "Background Location". If you manually activate this channel and restart the app, the tracking notification is still not shown.
We have the issue solved. It is the new permission requirement from SDK 34 (Android 14).
You have to add this line to your manifest:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION"/>
In addition, after you upload your app to Play Console with this permission declaration, you will have to fill Foreground service permissions policy under App content.
It would be great to add this new line to the current README. https://github.com/Baseflow/flutter-geolocator/blob/026534d34d56226d51b348ed46397055520c1e7f/geolocator/README.md?plain=1#L68
Hi @tsungweihsu, thanks for your suggestion.
We made this adjustment and it worked.
On top of that we forced that our functionalities can only be used when "Always in use" is on. This was necessary since we use background location measurement.
Thanks for the tip.
This solved my problem: https://stackoverflow.com/a/76943772/3426262
I had to add the permission <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
Please check the following before submitting a new issue.
Please select affected platform(s)
Steps to reproduce
It seems to happen only on certain Android devices.
Expected results
Distance is registered along the way.
Actual results
No distance registered.
Code sample
Code sample
```dart void startPositionStream({ required void Function(Position) onPositionChanged, required Function onError, }) async { // Cancel stream, if there is any await cancelPositionStream(); // Start listening to the position stream _positionSubscription = Geolocator.getPositionStream( locationSettings: _initializeLocationSettings(), ).listen( onPositionChanged, onError: onError, ); } void _onPositionChanged(Position position) { gpsPositions.add(position); gpsPositions = _gpsFilterService.filterOutAnomalyPoints( positions: gpsPositions, activityType: _challengeActivityType); // Calculate distance double totalDistance = _gpsAPI.calculateDistance( positions: gpsPositions, ); // Add to sink final GpsModel gpsModel = _gpsModel.cloneSettingsAndMeters( meters: totalDistance, ); gpsStreamController.sink.add(gpsModel); } double calculateDistance({ required ListScreenshots or video
Screenshots or video demonstration
[Upload media here]Version
11.0.0 (geolocator_android = 4.4.1)
Flutter Doctor output
Doctor output
``` [!] Flutter (Channel unknown, 3.10.0, on Microsoft Windows [Version 10.0.22631.3447], locale en-NL) ! Flutter version 3.10.0 on channel unknown at C:\flutter_windows_2.2.3-stable\flutter Currently on an unknown channel. Run `flutter channel` to switch to an official channel. If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install. ! Unknown upstream repository. Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install. • Framework revision 84a1e904f4 (12 months ago), 2023-05-09 07:41:44 -0700 • Engine revision d44b5a94c9 • Dart version 3.0.0 • DevTools version 2.23.1 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at C:\Users\bart_\AppData\Local\Android\sdk • Platform android-34, build-tools 31.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [X] Visual Studio - develop for Windows X Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [√] Android Studio (version 2020.3) • Android Studio at C:\Program Files\Android\Android Studio1 • 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 11.0.10+0-b96-7249189) [√] Android Studio • Android Studio at C:\Program Files\Android\Android Studio • 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 • android-studio-dir = C:\Program Files\Android\Android Studio • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) [√] VS Code (version 1.88.1) • VS Code at C:\Users\bart_\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.88.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.3447] • Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.118 • Edge (web) • edge • web-javascript • Microsoft Edge 124.0.2478.67 [√] Network resources • All expected network resources are available. ```