Android Question GPS sharing...

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
I have been confused with the following issue:
In my app, I need to receive GPS location data even if I have another app open (e.g. a navigator).
By now, I stop the GPS listening on Activity_Pause and start it again on Activity_Resume.
If I leave the GPS listening open, will the app receive the data if I open the other app that uses the GPS or it's dangerous to have a conflict?

Thank you in advance.
 

KMatle

Expert
Licensed User
Longtime User
If I leave the GPS listening open, will the app receive the data if I open the other app that uses the GPS or it's dangerous to have a conflict?

The world will stop spinning at once No. Multiple apps can use the location manager parallel No problem. No problem. Even Google uses it multiple times in the background (e.g. Google Now) or additional Facebook.

I have my service defined as "sticky":

B4X:
#Region  Service Attributes
    #StartAtBoot: true
    #ExcludeFromLibrary: True
    #StartCommandReturnValue: android.app.Service.START_STICKY
#End Region

I have a timer included to push the location to my MySQL DB via OkHttpUtils every x seconds. I did some tests (phone in my car, screen switched off, no wakelock change). Worked for 5 hours without problems (service was alive after that).
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Hello @KMatle!
Thank you for your reply!
This specific app, uses only the GPS library instead of location manager. The reason for this, is that it's "harmful" to use location manager because I need instant best accuracy.
It would be catastrophic to use network approximate location. It's a taxi dispatching app.
So, will GPS library do what I need?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…