Acquire wakelock or foreground service via flutter ?

648 views
Skip to first unread message

Ian B

unread,
Nov 15, 2018, 5:43:41 AM11/15/18
to flutt...@googlegroups.com
Hi all,

I am trying to get an app working that ideally needs to run, even if the screen is off. This is as it needs GPS coordinates frequently.

As soon as the screen goes off, gps locations aren't returned. I've hacked around this just to test, by forcing the screen on, which solves that issue. But it uses too much battery with the screen on all the time.

Is there any way to keep an app running (to get GPS notifications), I've read about wakelocks and foreground services, but can't seem to find anything that applies to flutter in how this may be achieved.

Tia, Ian

Şükriye Ludwig

unread,
Nov 15, 2018, 5:55:40 AM11/15/18
to ibri...@gmail.com, flutt...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ian B

unread,
Nov 15, 2018, 12:28:29 PM11/15/18
to suekriy...@gmail.com, flutt...@googlegroups.com
Thanks Sue,

I had a read through, it looks a bit beyond me if I'm honest, and then I don't know if it will still work :).

It's a tad ironic that Androids battery saving measures stopping GPS with the screen off, means you ended up needing to run the app with the screen on, wasting far more battery!

Ian


Jaime Baum

unread,
Mar 5, 2019, 3:51:27 PM3/5/19
to Flutter Dev
Hi Ian, were you able to find a solution? I'm having the same requirement for an app I'm working on.

Ian B

unread,
Mar 5, 2019, 5:34:36 PM3/5/19
to Jaime Baum, Flutter Dev
Hi Jaime,

It wasn't possible in my particular case, as the devices I was testing had it hardcoded in the chipset to turn off the gps when the screen was off (I can understand this, as it was for Android Wear where battery is at a premium). So I ran with a dimmed black screen with small writing. Hard to tell if that made any difference or not.

If it's designed more for mobiles, you may not have that issue though.

Ian 

--
Reply all
Reply to author
Forward
0 new messages