Android Question Help/Suggestions needed to retrieve device's Lat and Long on demand

Anser

Well-Known Member
Licensed User
Longtime User
Hi Friends,

My requirement:-

I am looking for a solution to retrieve the device's latitude and longitude and write it to a remote database SILENTLY.

I don't want the device to write the Lat and Long to the remote database in a scheduled manner, for eg every 15 minutes or 30 minutes, INSTEAD, whenever a DESKTOP APP user demands the location of the device, my B4A app should write the Lat and Long to the remote database. My total solution is a mix of desktop app and B4A app.

Whenever the DESKTOP application requests for the Android device's location, the B4A app should write the lat and long to the remote database without any notification on the B4A app ie the B4A user should be totally unaware that a location request has come from the Desktop app and the B4A provided those information.

Hope I made my requirements clear.

After giving some thoughts, I have come up with an idea but not sure whether this is the right solution or not, OR is there any other better solutions to achieve the above said requirement.

  • I already use Google Cloud Mesaging (GCM) in B4A
  • I am able to send GCM messages from the DESKTOP application to B4A app
  • I already use FusedLocationProvider in many activities in the B4A app.
Suppose If I send a GCM message from the DESKTOP app, with some extra information to identify that it is a location update request.
The B4A app after receiving this GCM message should not show any notification on the B4A app, it will silently update the remote database with the device's latitude and longitude. Once the remote database is updated with the device's current latitude and longitude, I can show the device's location on the DESKTOP application.

If the above said GCM Service can serve the pupose, then I don't know
  1. How to get the Lat/Long from FusedLocationProvider without showing/using any activity screen to the user.
  2. How to process the GCM message (demanding the location details) without showing any notification to the user.

Any help will be appreciated.

Regards
Anser
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
2.
How to process the GCM message (demanding the location details) without showing any notification to the user
This is simple. The service will start without showing anything to the user.

About the location, you can get the last known location. It will most probably won't show any icon.
 
Upvote 0
Top