Android Question Mock Locations with New Fused_Location_Provider_GMS lib

Harris

Expert
Licensed User
Longtime User

I have built an app (2 actually) using this lib to try and mock locations.
Studied everything with regards to how to make work, yet - FusedLocation_LocationChanged event won't fire when feeding mock locations?

Essentially, you must create 2 apps. One to FEED mock locations, and another to RECIEVE these LocationF things...

So, I select my "Mock app" in developer settings (to broadcast "fake" locations)..
I SetMockMode = true...
Then I broadcast SetMockLocation( mlocation ) from the sender app (using a sql table to pop new lat / lon - and the other required stuff).

Funny, the receiver app sees the "last known location" - from the sql published results - but never raises the FusedLocation_LocationChanged event....
Strange...

Before I post the project - anyone have any informed insight? (success doing the same)?
I just hate to bug the crowd when may be something simple I am overlooking (after 2 weeks screwing / google searching for such a resolve).

Thanks
 

Harris

Expert
Licensed User
Longtime User
Making very good headway, finally.... (after 2 days of beating head against wall)

It mostly had to do with this: et="?!?" This is a parameter of the "LocationF" object (elapsed time since last fix ).
Without a valid value, a Mock Location will not get published! Discovered when logging a LocationF...
******************************
Example LastLocation - LocationF
pos: 11 locat: (Location) Location[flp 57.861847,-152.641979 hAcc=20 et=+1d9h50m11s900ms alt=931.300048828125 vAcc=2 sAcc=2 bAcc=45 mock {Bundle[mParcelledData.dataSize=524]}]
*******************************
Note: et is declared as a long value - yet this is returned as valid ( +1d9h50m11s900ms ) - how is that a Long?

There is no way to set this when mocking locations because the param properties do not provide it - only "mlocation.Time"...

There is a workaround for obtaining "A" legit value.
1) Create a global var - Public Lloc as LocationF (and init it)

When setting up the Fused Location Object - get a valid return of the current location...

Wait For FusedLocation_LocationRequestCompleted (Result As LocationResult)
If Result.Status=LocationResult.STATUS_SUCCESSFUL Then
If Result.Location.IsInitialized Then
Dim LastLocation As LocationF = Result.Location
Lloc = LastLocation ' IMPORTANT

..... Set it to the object that contains a valid "et". (mLocation = Lloc)
later.... Update the time, lat / lon of mLocation LocationF - and it will get broadcast to the Receiving App. (with other caveats)...

I have a SQL table that I populate the Lat / Lon (of LocationF) for many (selected) roads in Alaska - each Mile Marker location (supplied the AK DOT).
Mocking these points allows me to test many things without having to "drive" the road in real time.

More to come.
When finished, I shall post a functional, documented project of a New (modern) Mock Location Provider tool- using:

Fused_Location_Provider_GMS​

Thanks
 
Upvote 0
Top