Flutter live tracking

3,897

I solved background location service in Flutter by using platform-channel. I have combined android foreground service ( yes foreground, accessing GPS location in background does not allow for real-time.)

enter image description here

I have solved real-time background location flutter app for Android by using Platform Channel, Android Foreground Service. It's work perfectly whenever screen is ON or Off and you don't need to wakeup the screen the whole time to get location update.

Image Source : https://flutter.dev/

https://flutter.dev/docs/development/platform-integration/platform-channels

Share:
3,897
Shayan khan
Author by

Shayan khan

Updated on December 18, 2022

Comments

  • Shayan khan
    Shayan khan over 1 year

    I am new to flutter development, with android background, i am developing an app for live tracking with flutter using "location" third party api link : https://pub.dev/packages/location how ever in most devices the location stream stops when app is in background and the phone is not in use, after a certain time, i am unable to work around this issue have included this api as well but it wont launch the service again, link : https://pub.dev/packages/background_fetch but they dont seem to solve my problem, if anyone has worked with tracking on flutter application please do share.

    Thanks

    The result i am asking for. no matter the state of the phone location should be fetched and posted to server given the app is in background and the phone not in use.

    Edit: 27-11-2020 As it turns out there was no solution and this is not related to flutter, but android in general. For people with this issue please read through DOZE MODE it was introduced in android 6.0 on-wards. The solution I did was to attain wake lock, and keep the screen on so to avoid doze mode but this is not the most optimized solution obviously.

  • Shayan khan
    Shayan khan almost 3 years
    I will have to test it out, unfortunately i do not have the time, how ever i still doubt it is possible but do check with doze mode, use this link -> developer.android.com/training/monitoring-device-state/…