This object is in archive! 

Public intent to start recording sometimes doesn't enable GPS

Ingo Rau shared this problem 9 years ago
Solved

This is a bit special problem and I can't reproduce it, but it's kinda severe:

For travel, I defined some tasks that automatically enable the phone's GPS and then start Locus recording, using the public intent locus.api.android.ACTION_TRACK_RECORD_START (I wanted to link to the manual page here, but http://docs.locusmap.eu/doku.php?id=manual:locus_api:public_intents gives an error...).

This worked quite well - most of the time. But in a few cases I later realized that GPS was turned on, Locus was in recording mode, but within Locus, GPS wasn't enabled - so nothing was being recorded effectively.

That was quite a blow, as I lost my track until then. Unfortunately, when I tried to reproduce it, it always worked.

Is there some condition under which the intent doesn't enable GPS within Locus, or is this a bug?

Replies (9)

photo
1

Hello Ingo,


a few months ago, I had similar experience not based on intent, but a regular usage. When GPS was turned off after turning screen on and off fast. Unfortunately same as you, I was never able to reproduce this problem. Without this, I'm really unable to fix it.


If you find something what may helps, definitely tell me!

photo
1

Well, good to know it's not just me ;)

I will try it again with my holiday setup. I once thought it only happened when I closed Locus before (double-back within Locus), but I think it also happened in other cases.

Perhaps you can tell me if I understand it correctly: Does the widget also call these intents or does it do more? It never happened to me when using the widget, but I rarely used the widget instead of my automatic tasks, so it could just be coincidence.

photo
1

Nope, it is not the same. Widget directly control track recording by calling internal Locus functions. So you tap on widget button - it calls function. Intent has to be firstly received by any receiver that consume it and then call same function. Not a big difference any and I also think that this do not be a source of problems.


In Locus is quite complicated logic when GPS should be turned on/off based on various conditions. So I more think that some feature lost it's race (information that GPS is needed was received on certain place too late). But as I wrote, without ability to simulate it, quite hard to solve mainly when it happen sooooo rarely.

photo
1

Hi there!

So I managed to get the error again, but then I couldn't reproduce the steps leading up to it. Anyway, I'm just telling you what I did so far, and then try again.

I made a task (with E-Robot, but I think that doesn't matter, similar to Tasker) that activates the phone's GPS and then starts Locus recording via intent. It's automatically called whenever I turn off the screen. I played around with it for a while, turning recording an/or GPS off again manually, until I suddenly, whenever the screen was turned on again, the "GPS Disabled" toast from Locus appeared, and when I checked in the app, Locus was still in recording mode (and phone's GPS was on), but didn't record.

So I think we can confirm that it has to do with turning the screen on. I actually remember that on holiday, sometimes there was already a recorded track, so the starting of track recording worked, but next time I turned the screen off and later on again, it stopped.


As I said, I will try more, but at least we're a little closer to the situation where it happens...

photo
1

Additional obsertion:

When using the intents, the widget is not updated, i.e. when I start recording by intent, the widget is still in "not started" mode, doesn't update the current track statistics and only the green button is activated.

I assume this is rather a problem with the widget and not related, but I thought I'd mention it - perhaps it shows that some part of Locus doesn't know about a track being recorded right now.

photo
1

We will see in next version, I did a small improvement which should solve this problem. At least I hope :)


And yes, it has for sure nothing to do with main problem here ...

photo
1

Thx, better than nothing ;)

photo
1

Back to main problem:

I thought I managed to find a "recipe" to reproduce the bug, worked several times, but then didn't anymore. I can only assume timing is involved at some point here, so I'll still post it here, in case that gives you some hint:

  1. Exit Locus (I also killed it in Taskmanager, but afaik that sholdn't make a difference)
  2. Start recording by using the intent, that means in the background
  3. Wait until at least 2 points are recorded (otherwise Save dialog will not appear)
  4. Stop recording, chose delete in Save dialog (probably doesn't matter if you save it, I assume the important thing is that the Locus app wasn't opened, just the dialog)
  5. Start recording again
  6. Turn off screen
  7. (Insert possibly important waiting time here ;)
  8. Turn on screen - Locus toast "GPS disabled" is shown, status bar confirms that GPS is not used anymore

I know, may be something entirely different - once I get the bug, I get it consistently several times in a row with steps 5-8, so the culprit may have been even earlier, something other than 1-4.

But it's definitely a real existing problem, not just a fluke.

Staying on it, but perhaps this helps some way...

photo
1

I think this can safely be marked as "Solved" - it's been 3 years with lots of using this function without any problems...

photo
1

Ah perfect, glad to hear it. Maybe you do not know, I started work on new system for control of app. If you use Tasker, maybe you find this useful as well: https://github.com/asamm/locus-api/wiki/Action-tasks-(Broadcasts) .

Jiří M. aka Menion

photo
1

Yeah, I know - I actually asked you for the "preset" intent (slarti76 in forum). Works in 3.31.1, thx!

Is there any advantage in changing the existing (old-style) intent for start/stop recording to the new one (Broadcast)?

photo
1

Ah right, sorry, too many people around :).

Advantage ... old system call in app the new system, so both should work almost same. The new system has even now more options, that's all.

Replies have been locked on this page!