GPS quickly drainin power...

tigrot

Well-Known Member
Licensed User
Longtime User
Hi Everybody
Happy Easter, first of all...
I'm fighting with a power eater GPS application. I have a 10 minutes wait, after that I enable GPS events with start method. After 2 minutes I use the stop method and enter a wait for a new timer event. The program is always sleeping.
Although I don't use processor, after initialising GPS object I find that the GPS icon on top is always active, till I cancel or terminate my APP.
The battery is fading away in 12 hours or so...
Does anybody knows how to deactivate GPS hardware, after GPS.Initialise ?
I use extended location manager. Since it has no way to get speed i use it along an instance og regular GPS library. I stop both of them, but the "target" icon is still there on top...:sign0148:

Ciao
Mauro
 

agraham

Expert
Licensed User
Longtime User
With this trivial program I can see the GPS icon in the notification area toggle on and off as I press the button so there doesn't seem to be any problem with either of the libraries.
B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

   Dim Button1 As Button
   Dim gps1 As GPS
   Dim esl As ESLocation2
   Dim on As Boolean
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Activity.LoadLayout("Layout1")
   If FirstTime Then
      gps1.Initialize("")
      esl.Initialize("")
   End If
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub


Sub Button1_Click
   If on Then
      on = False
      gps1.stop
      esl.stopGPSListening
      ToastMessageShow(on, False)
   Else
      on = True
      gps1.Start(0, 0)
      esl.requestGPSLocation(0,0)
      ToastMessageShow(on, False)   
   End If   
End Sub
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
Nice of you!

Thank you Agraham,
I was loosing hope to get feet out of the mud!
Now I'm testing the program over again to find the issue.
I'm writing for free for an Alzheimer unpaired people association in Rome. While we do that I'm looking for a way to help women against violence.
There is so much work to do...

Ciao
Mauro
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
Here is the solution

Problem solved...
On first cycle the istructions:
gps1.Start(0, 0)
esl.requestGPSLocation(0,0)

were hit twice. The system was thinking there were two users of GPS hardware. So next stop/start didn't deactivate/activate the GPS.


Ciao
Mauro
 
Upvote 0
Top