Android Question Mock Location doesn't accept Lat/Lon


Active Member
Licensed User
Hi everyone,
I've tried to use the mock-locationprovider-lib and successfully simulated a location with it (after setting the target API down to 16 because of a deprecated library function which doesn't set a specific value that's required on newer API's, but anyways), but I'm struggling to set a specific Lat/Lon value to it.

If I take the example that is:
latitude="5234.1421"        'lat. as decimal_degrees
ns="N"                    'north-south = NORTH
longitude="01311.7996"        'long. as decimal_degrees
we = "E"                    'west-east = EAST
altitude="84.0"                'alt. as meter     
speed="0.0"                'speed as km/h
bearing="75.0"            'cuorse as degrees
accuracy="2.0"            'accuracy of horizontal position fix in relation to used sattelites position as meter
it simulated a location somewhere in Germany, which is totally fine.

Now I've tried to put Lat/Lon values there -16.3000000 and -48.9300000 but the library doesn't like that and spits an error out that
java.lang.NumberFormatException: Invalid float: "0.6.000000"
at java.lang.StringToReal.invalidReal(
at java.lang.StringToReal.initialParse(
at java.lang.StringToReal.parseFloat(
at java.lang.Float.parseFloat(
at esolutions4you.B4A.moclocationprovider.moclocationprovider.publishMockLocation(
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(
I've tried to omit the negative sign and use ns="s" and we="w" but it still compained. Etc etc.

I'm trying for literal days now and have no clue on how to convert Lat/Lon to this format (it's not even normal decimal degress, it's something else).

Any help is welcome


Active Member
Licensed User
There's just one problem with this library: It's deprecated and works only with API 16 or less (Up to Android 5 only).
Do you know how to do things with the Reflection library, by any chance?
If we could simulate the GPS mock locations via Reflection, all these things wouldn't be necessary and users could use it on the latest API.
The problem is that Google will be (or already is?) forcing API 26 for their Apps in the Play Store and those who aren't able (for this and other reasons) to update it to this API, can't update their Apps anymore.
For me in particular using API 16 is no problem because this project is a hobby car multimedia project and won't be published, as it isn't necessary. But for others, having no mock GPS library or integration whatsoever in B4A, is bad, I think.
Upvote 0