Android Question [RESOLVED] GPS NMEA event not firing on Android 10

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hello

I have a similar post https://www.b4x.com/android/forum/t...r-android-studio-emulator.111671/#post-696445 which is most likely related to this one.

I had to go and buy a One Plus 7T this week for various reasons. I installed the app that is having the issue my previous post. In the service that runs the GPS the only data I get is the LocationChanged event data, the location object. The NMEA event is not firing at all. I need this event to fire.

I am using the B4X gps library and have the correct permissions.

Has anyone tested this on android 10.

Regards

John.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi Erel

There is one issue in my code, not yours. In the stopGps function I trap and error :

12/13/2019 09:02:53.904 - StopGps, error - java.lang.ClassCastException: Couldn't convert result of type int to boolean

B4X:
Public Sub StopGps
   
   mGps.Stop
   Try
       If phone.SdkVersion >= 24 Then
           LocationManager.RunMethod("removeNmeaListener", Array(nmea))
       End If
   Catch
       mod_functions.writelog("StopGps, error - " & LastException.Message)
   End Try
   
   StopService(Me)
   
End Sub

When I start the GPS service again again from within the app, I get the same error on the startGps:
B4X:
Public Sub StartGps
   
   mGps.Start(0, 0)
   Try
       If phone.SdkVersion >= 24 Then
           nmea = LocationManager.CreateEventFromUI("android.location.OnNmeaMessageListener", "nmea", 0)
           LocationManager.RunMethod("addNmeaListener", Array(nmea))
       End If
   Catch
       mod_functions.writelog("StartGps, error - " & LastException.Message)
   End Try

   mod_functions.writelog("**** GPS STARTED ****")
   

End Sub

However, the NMEA listening still appears to work. All the above code is in a service obviously.

Any thoughs on this ?

Regards

John.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Upvote 0

BlueVision

Active Member
Licensed User
Longtime User
Just invested hours in finding a failure within my code. There are rare situations when this routine gives out an "unexpected zero". I will put a picture below. In my program two "NMEA"-routines are running, the old fashioned one and the new one above, so the program can give NMEA-altitude-measurements on older android versions and newer ones.

A little bit hard to explain what my code does...
Short, a flag will be set if the new NMEA-code gives out a valid value. If valid, an altitude below zero is not needed, it will set to zero by code. After that I have to split the altitude-value into seperate digits for assigning it to a special graphical view (digit will be displayed within a bitmap, desing needs it). So I have to know the length of the altitude-string for calculating digit position and picture to be loaded (centering reasons and again graphical needs). The following string operation must fail based on the length of the string of the altitude (there the error comes up, the debugger is pointing to that line) "-0" is different to "0", a length mismatch and my code tryed to put a digit-bitmap to the minus sign and failed.

Look at the picture now. In the right pane you can see the error. The routine gives out a "-0" under some cirmumstances. I waited hours to catch this error. So normally a zero is zero and not minus zero. Knowing about that problem is enough, so there is simple workaround when working with integers in that special case.

If Altitude < 0 Then Altitude = 0
changes to
If Altitude < 1 Then Altitude = 0

This will hopefully fix this issue.

Not a big thing, but it may a little help when working with the routine above. Hopefully nobody of you has to spent hours for hunting of this. That's the reason for this post.

Cheers BV

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…