Nov 14, 2010 Replies: 311 The GNSS library replaces the old GPS library. The GNSS library is available here: https://www.b4x.com/android/forum/threads/gnss-library-an-updated-gps-library.109110/#content Using it is quite simple: 1. Checking whether location services are available. If not take the user to the settings. 2. Request permission. If the purpose is to get the user location then the FusedLocationProvider might be a better option: https://www.b4x.com/android/forum/threads/fusedlocationprovider-resolution-dialog.111652/#content Attachments GPSExample.zip GPSExample.zip 15 KB · Views: 1,229 Last edited: Mar 13, 2025 Click to expand...
The GNSS library replaces the old GPS library. The GNSS library is available here: https://www.b4x.com/android/forum/threads/gnss-library-an-updated-gps-library.109110/#content Using it is quite simple: 1. Checking whether location services are available. If not take the user to the settings. 2. Request permission. If the purpose is to get the user location then the FusedLocationProvider might be a better option: https://www.b4x.com/android/forum/threads/fusedlocationprovider-resolution-dialog.111652/#content
schimanski Well-Known Member Licensed User Longtime User Dec 2, 2010 #2 Result of bearingto is negativ Hello! I have calculate the bearing from my own position to the target-position with B4X: Expand Collapse Copy Kurs=GPS1.BearingTo(Target) The result of Kurs is negativ and not equal with the real bearing.
Result of bearingto is negativ Hello! I have calculate the bearing from my own position to the target-position with B4X: Expand Collapse Copy Kurs=GPS1.BearingTo(Target) The result of Kurs is negativ and not equal with the real bearing.
Erel B4X founder Staff member Licensed User Longtime User Dec 2, 2010 #3 GPS1 is a location object? How did you initialize the Target? Can you post the values of GPS1, Target and Kurs. B4X: Expand Collapse Copy Log(GPS1) Log(Target) Log(Kurs)
GPS1 is a location object? How did you initialize the Target? Can you post the values of GPS1, Target and Kurs. B4X: Expand Collapse Copy Log(GPS1) Log(Target) Log(Kurs)
schimanski Well-Known Member Licensed User Longtime User Dec 2, 2010 #4 Hello Erel! Is it possible, that the bearing is not shown in 0-360°? When it is shown from 0-180 and -180 to 0°, I think it is correct...:sign0013:
Hello Erel! Is it possible, that the bearing is not shown in 0-360°? When it is shown from 0-180 and -180 to 0°, I think it is correct...:sign0013:
Erel B4X founder Staff member Licensed User Longtime User Dec 2, 2010 #5 This is probably the case here.
peacemaker Expert Licensed User Longtime User Dec 17, 2010 #6 So, isn't possible programmatical on\off (connect\disconnect) of Android's GPS subsystem (like in WM 5.x-6.x)? Without manual user's choice. I mean periodical GPS auto-connect by a software only.
So, isn't possible programmatical on\off (connect\disconnect) of Android's GPS subsystem (like in WM 5.x-6.x)? Without manual user's choice. I mean periodical GPS auto-connect by a software only.
agraham Expert Licensed User Longtime User Dec 17, 2010 #7 peacemaker said: So, isn't possible programmatical on\off (connect\disconnect) of Android's GPS subsystem (like in WM 5.x-6.x)? Without manual user's choice. Click to expand... No, it's not possible. As Erel stated above. Due to privacy concerns the Android OS doesn't allow you to turn the GPS on programatically. Click to expand...
peacemaker said: So, isn't possible programmatical on\off (connect\disconnect) of Android's GPS subsystem (like in WM 5.x-6.x)? Without manual user's choice. Click to expand... No, it's not possible. As Erel stated above. Due to privacy concerns the Android OS doesn't allow you to turn the GPS on programatically. Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Dec 19, 2010 #8 You can't enable or disable the GPS device. However if it is enabled it will turn on when it needed and off when it is not needed (to save battery).
You can't enable or disable the GPS device. However if it is enabled it will turn on when it needed and off when it is not needed (to save battery).
peacemaker Expert Licensed User Longtime User Dec 19, 2010 #9 Ha, so this is enough. Just an extra manual permission from a user, i see. Thanks, Erel. Now just interesting about background running application and switching the screen off, again for battery economy. Last edited: Dec 19, 2010
Ha, so this is enough. Just an extra manual permission from a user, i see. Thanks, Erel. Now just interesting about background running application and switching the screen off, again for battery economy.
Z ZJP Active Member Licensed User Longtime User Dec 22, 2010 #10 Hi, Good work but what about the NMEA ? ( hxxp://developer.android.com/reference/android/location/GpsStatus.NmeaListener.html ) How to get those frames? Thx Last edited: Dec 22, 2010
Hi, Good work but what about the NMEA ? ( hxxp://developer.android.com/reference/android/location/GpsStatus.NmeaListener.html ) How to get those frames? Thx
Erel B4X founder Staff member Licensed User Longtime User Dec 23, 2010 #11 The raw sentences are not exposed for now.
A ashrafidkaidek Member Licensed User Longtime User Jan 10, 2011 #12 Why when I try this code no message shows up when pressing the home button? B4X: Expand Collapse Copy Sub Activity_Pause (UserClosed As Boolean) Dim Results4 As Int Results4 = Msgbox2("Just a msg", "Try","OK", "", "", LoadBitmap (File.DirAssets,"Signal.png")) If Results4 = DialogResponse.POSITIVE Then End If GPS1.Stop Awake.ReleaseKeepAlive End Sub Thanks
Why when I try this code no message shows up when pressing the home button? B4X: Expand Collapse Copy Sub Activity_Pause (UserClosed As Boolean) Dim Results4 As Int Results4 = Msgbox2("Just a msg", "Try","OK", "", "", LoadBitmap (File.DirAssets,"Signal.png")) If Results4 = DialogResponse.POSITIVE Then End If GPS1.Stop Awake.ReleaseKeepAlive End Sub Thanks
Erel B4X founder Staff member Licensed User Longtime User Jan 10, 2011 #13 You cannot show a msgbox when the activity gets paused. It is not possible to suspend the pausing process (the msgbox is automatically dismissed).
You cannot show a msgbox when the activity gets paused. It is not possible to suspend the pausing process (the msgbox is automatically dismissed).
A ashrafidkaidek Member Licensed User Longtime User Jan 10, 2011 #14 Thanks Erel, I have noticed one other thing that dose not make since to me: I have created a small GPS app following your example above; (just to understand the process correctly). What I have tried to do is to make the app shows all the information to the user (Lat, Lng. …) and do some other tasks in the background (track the user movement). What I have noticed that while the app is running everything works fine until the user gets a phone call which forces my app to pause, and force the GPS to turn off, therefore I changed the code as shown below: B4X: Expand Collapse Copy Sub Activity_Pause (UserClosed As Boolean) End Sub Note: I have added an if statement to the “Activity_Resume” sub to insure that I’m not calling GPS1.Start while the GPS is already on) Now when the app being pushed to the background because of a phone call (or maybe the user decided to play music or surf the Internet) the GPS will stay on, but the application somehow will be paused (the tracking function is not recording anything while the application is in the background) Is this issue due to Android hardware limitation? If yes then how come you can play music and surf the Internet at the same time? Thank you all Last edited: Jan 11, 2011
Thanks Erel, I have noticed one other thing that dose not make since to me: I have created a small GPS app following your example above; (just to understand the process correctly). What I have tried to do is to make the app shows all the information to the user (Lat, Lng. …) and do some other tasks in the background (track the user movement). What I have noticed that while the app is running everything works fine until the user gets a phone call which forces my app to pause, and force the GPS to turn off, therefore I changed the code as shown below: B4X: Expand Collapse Copy Sub Activity_Pause (UserClosed As Boolean) End Sub Note: I have added an if statement to the “Activity_Resume” sub to insure that I’m not calling GPS1.Start while the GPS is already on) Now when the app being pushed to the background because of a phone call (or maybe the user decided to play music or surf the Internet) the GPS will stay on, but the application somehow will be paused (the tracking function is not recording anything while the application is in the background) Is this issue due to Android hardware limitation? If yes then how come you can play music and surf the Internet at the same time? Thank you all
Erel B4X founder Staff member Licensed User Longtime User Jan 11, 2011 #15 No code runs when the activity is paused.
Z ZJP Active Member Licensed User Longtime User Jan 11, 2011 #16 That means it is impossible to have a background processing? JP
Erel B4X founder Staff member Licensed User Longtime User Jan 11, 2011 #17 Not with activities. In the future there will be support for services which support background processing.
Not with activities. In the future there will be support for services which support background processing.
A ashrafidkaidek Member Licensed User Longtime User Jan 11, 2011 #18 Erel, If I understand this correctly, this is a Basic4Android limitation, it is not Android operating system limitation, is that right? And when you say in the future dose that means the next Basic4Android version? Regards :sign0148:
Erel, If I understand this correctly, this is a Basic4Android limitation, it is not Android operating system limitation, is that right? And when you say in the future dose that means the next Basic4Android version? Regards :sign0148:
Erel B4X founder Staff member Licensed User Longtime User Jan 11, 2011 #19 If I understand this correctly, this is a Basic4Android limitation, it is not Android operating system limitation, is that right? Click to expand... No, that is not correct. This is Android OS limitation (or actually design). And when you say in the future dose that means the next Basic4Android version? Click to expand... It is planned for the next major update.
If I understand this correctly, this is a Basic4Android limitation, it is not Android operating system limitation, is that right? Click to expand... No, that is not correct. This is Android OS limitation (or actually design). And when you say in the future dose that means the next Basic4Android version? Click to expand... It is planned for the next major update.