1

my device to test is huawei
Is it possible for the android application to work even while the screen is off?
In my application does not work:
- wakefullbroadcastservice + alarmmanager,
- service + alarmmanager,
- gps settings old method and new google.api.client,
- use wakelock in service and activity,
- set gps in service, activity and separate class,
all that does not work because:
- or go to lock screen and gps saves every 10 or 20 seconds to file the same longitude and latitude only as unlock screen then it starts real data saving,
-or saves various data when the screen is switched off it ceases to write eg 10-20 or 27,or 18 min without any repetition, and then again writes other data often not changing their values ​​latitude, longitude,

I've figured out all the possibilities that the internet gives and still does not work In general, this is for the application to save my latitude and longitude all the time even when I have locked the screen, and writes to the file all that every 10-20 seconds, is it possible at all? Why not why? I am currently wakelock in the activity and I start listening to the location in the activity ,and the data latitude,longitude with time saves to the file using service and then shut it down ... Please help because the massacre :)

3 Answers3

0

You have to turn off the battery optimization on power saving mode for your app. Settings -> Battery -> top menu "Battery optimization". This is not available on older Versions like 4.2.2. I'm not sure but i think it was coming with 6.0

Fusselchen
  • 382
  • 1
  • 4
  • 12
0

Prerak Sola-> i have tried every examples whose i found on stack, and blogs, There was too much to write here, others were happy, they worked for them wery well...
sumit-> yes i did..
Nick Isaacs -> yes and you have right its work fine but gps send me these same values of latitude and longitude when i lock my screen, till i unlock, then works wery well(when screen is on)
Fusselchen-> yes this is one of the ones I did not do that I did not update android, i have 5.1.1, i will try to do this today, if its possible..., but the topic is open, and question: Is there some someone who had the same problem i mean version of android <6 which the cause of bad working gps track?
Thanks!!!

0

I had noticed that when accurancy is above 300-350 meters my location latitude and longitude isn't changing... when is below it is works very fine, so i guess it is cause of "freeze" value of latitude and longitude how you think abut that? ( my accurancy can be even 3500 meters !(only gps is on) wifi+gps max is abut 900 m). I do not have possibility to check my program on (android >= 6)... I also tried test another apps like gpsTracker and they also worked badly...