Android Question Help! WiFi location not working under 4.4.2

jefflynn1974

Member
Licensed User
Longtime User
I have an application which ask for WiFi location on several types of mobiles. Those users who tests my app under Android 4.4.2 can't get any location data via wireless. I tried out with two location libaries too (ABWiFi and Expanded Location Manager Libary) so it seems it is a general problem with KiKat!

Please help,
Jeff
 

derez

Expert
Licensed User
Longtime User
I tried the following test program on nexus 5 with 4.4.2 and it works. It uses esLocation2 library.
Prior to running I changed Location setup to the middle position which is no GPS, just network.
B4X:
Sub Process_Globals
Dim lm As ESLocation2
Dim tmr As Timer
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
tmr.Initialize("tmr", 1000)
tmr.Enabled = True
lm.Initialize("lm")
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub tmr_tick
Dim mylist As List
mylist.initialize
mylist = lm.findLastLocation("network")
If mylist.Size > 0 Then
  Log( NumberFormat(mylist.Get(2), 0, 9) & " " &  NumberFormat(mylist.Get(3), 0, 9))
Else
  Log("no position")
End If
End Sub
 
Upvote 0

jefflynn1974

Member
Licensed User
Longtime User
I did some tests with three phones on 4.4.2. You can see the used code below. The first was a Nexus 4 with stock rom, it didn't have any problems with WiFi location, worked fine. The second was a Nexus 5 with also a full stock rom. It only worked when the SIM was not in the device. The third one a Huawei Ascend P1 with custom rom (Cyanogenmod) and nothing worked (with SIM or without it). They location settings were enabled, and tested with both high accuracy and battery saving mode too. So what is the conclusion? It seems the app is okay and the roms are buggy?

B4X:
Sub Activity_Create(FirstTime As Boolean)
    WIFI_LOCATION1
End Sub

Sub WIFI_LOCATION1
        lm.Initialize("Location")
        lm.requestNetworkLocation(0,0)
End Sub

Sub Location_LocationChanged (longitude1 As Double, latitude1 As Double, Altitude As Double, Accuracy As Float, Bearing As Float, Provider As String, Speed As Float, time As Long)
        lm.stopNetworkListening
        latitude = latitude1
        longitude = longitude1
        Msgbox(latitude & " " & longitude, "title")
End Sub
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Your code works in my nexus 5, I get one time log of the lat & long.
If I remove the lm.stopNetworkListening I get it continuously every few seconds.
 
Upvote 0
Top