Android Question Mock Location doesn't accept Lat/Lon

Fusseldieb

Active Member
Licensed User
Longtime 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:
B4X:
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(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:160)
at java.lang.StringToReal.parseFloat(StringToReal.java:323)
at java.lang.Float.parseFloat(Float.java:306)
at esolutions4you.B4A.moclocationprovider.moclocationprovider.publishMockLocation(moclocationprovider.java:95)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
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
 

Fusseldieb

Active Member
Licensed User
Longtime 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
Top