B4A Library Mock-LocationProvider Lib

schimanski

Well-Known Member
Licensed User
Longtime User
Yes, that was the mistake. Now, it runs:sign0060:

thanks....
 

schimanski

Well-Known Member
Licensed User
Longtime User
Is there a simple way to convert the coordinates from the normal b4a-format to the mock_location-format? I have tried some things, but the mock_location provider ignores all my tested formats. Only a manually string like the example does work....

Thanks for help...
 

schimanski

Well-Known Member
Licensed User
Longtime User
For example:

Latitude: 5134.5667
Longitude: 006.4574



Gesendet von meinem XT910 mit Tapatalk 2
 

schimanski

Well-Known Member
Licensed User
Longtime User
Hmmm, I have tried serveral things to change the normal decimal-coordinates to the following format, which I have to use for the mock-location provider, but I think, that are not decimal_degrees

B4X:
latitude="5234.1421"        'lat. as decimal_degrees
longitude="01311.7996"        'long. as decimal_degrees

Has someone a sub to change the normal decimal-degree like 50.7478484 to the format above?

Thanks for help...
 

bitstra

Member
Licensed User
Longtime User
Yes! here you go:

Here's how you convert latitude & longitude obtained from NMEA's GPGGA to decimal:

-------------/NMEA--------------/--------Decimal
latitude----/0302.78469 --------/-------03 + (02.78469/60) = 3.046412
longitude--/10141.82531-------/-------101 + 41.82531/60) = 101.6971


Notice that for latitude of 0302.78469,

03 ==> degress. counted as is

02.78469 ==> minutes. divide by 60 before adding to degrees above


Hence, the decimal equivalent is:
03 + (02.78469/60) = 3.046412



This way I convert the coordinates from NMEA Strings to dercimal in my GPS projects...

good luck

bitstra

 
Last edited:

schimanski

Well-Known Member
Licensed User
Longtime User
I forgot the divide by 60 before adding.:sign0148:

It works....:sign0060:
 

Quaki

Member
Licensed User
Longtime User
Hi this library works great but is it posssible to add one more thing to this library ? The number of satelites ? It could be usefuul
Quaki
 

entolium

Member
Licensed User
Longtime User
Hi this library works great but is it posssible to add one more thing to this library ? The number of satelites ? It could be usefuul
Quaki

I'm in agree with you. This is a fantastic library and I'm using in my project, but I want to add more parameters like speed and satelites
 

Andrei E

Member
Licensed User
Longtime User
How to convert gps location into the mock?
B4X:
Sub GPSService_LocationChanged (Location1 As Location)
    Latitude = Location1.Latitude             ' 52.12345678
    Longitude  = Location1.Longitude        ' 25.12345678
End Sub
My issue is wrong format. The mock can't accept my GPS locations
 

Andrei E

Member
Licensed User
Longtime User
or how to convert GPS values into the this mock?
example (18e Avenue lat: 45.562708 lon: -73.5948923)
 

carlos7000

Well-Known Member
Licensed User
Longtime User
Hello

Try to use the example but when trying to execute the program, an error is reported that informs:


 

Fusseldieb

Active Member
Licensed User
Longtime User
Hello

Try to use the example but when trying to execute the program, an error is reported that informs:
"not allowed to perform MOCK_LOCATION"

- Are you sure that the DEVELOPER options are enabled on your device?
- Are you sure that in the developer options "Allow mock locations" is ENABLED?
- Are you sure that you've set the permission in your app adding
B4X:
AddPermission(android.permission.ACCESS_MOCK_LOCATION)
inside the manifest editor?
- Have you set the target API to 16 (or below)? This is required by this library, as it's getting deprecated. Don't use it in production, as Google will force API 26 very very soon!
 
Last edited:

carlos7000

Well-Known Member
Licensed User
Longtime User
- Are you sure that the DEVELOPER options are enabled on your device?
- Are you sure that in the developer options "Allow mock locations" is ENABLED?
- Are you sure that you've set the permission in your app adding
- Add: AddPermission(android.permission.ACCESS_MOCK_LOCATION)
- Have you set the target API to 16 (or below)? This is required by this library, as it's getting deprecated. Don't use it in production, as Google will force API 26 very very soon![/QUOTE]

Mode Developer: OK.
Allow mock locations: ¿?
Set the permission in your app adding: ¿?
set the target API to 16: OK

My manifest:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddPermission(android.permission.ACCESS_MOCK_LOCATION)
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'CreateResourceFromFile(Macro, Themes.DarkTheme)
'End of default text.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…