Other where am I, simple

MohammadNew

Active Member
Licensed User
Longtime User
This is example very simple to get your location (indoor or outdoor or where you are)

It has small problem :

1 - when I run the app in debug mode it get lang and lat but the map cannot display ,,
but in release it is working fine .


2 - In some devices does not work , I tried on galaxy works , LG no , Lenovo no ,,

I think it needs add code in manifest ,, or something.

library inside the folder.
 

Attachments

  • GPSNew.zip
    377.9 KB · Views: 307

MohammadNew

Active Member
Licensed User
Longtime User
anybody here tri what the app needs.

on my device is ok work, but lenovo or htc and lg does not work ,,, same the code but deffirint devices

you can download the example and tell me what I write to work fine.

many thanks
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
Thanks alot

same code on galaxy really work fine but some devices does work .

this is my code :

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim lm As ESLocation2
    Dim myList As List   
   
    Private EditText1 As EditText
    Private EditText2 As EditText
    Private Button1 As Button
    Private mapWebView As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("l1")
   
    lm.Initialize("Location")
   
    myList.Initialize
    myList = lm.findLastLocation("null")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
    myList = lm.findLastLocation("null")   
   
    EditText1.Text = NumberFormat(myList.Get(12), 0, 9)
    EditText2.Text = NumberFormat(myList.Get(13), 0, 9)   
    '''''''''''''''''''''''''''''''''''''''''''''''''''
    mapWebView.LoadUrl("file:///android_asset/location_map.htm?lat="&EditText1.Text&"&lng="&EditText2.Text&"&zoom=16")
End Sub

this is logs :

B4X:
LogCat connected to: B4A-Bridge: LENOVO Lenovo P70-A
--------- beginning of main
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (service1) Create **
** Service (service1) Start **
** Service (service1) Destroy **
** Service (service1) Create **
** Service (service1) Start **
Connected to B4A-Bridge (Wifi)
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:anywheresoftware.b4a.designer
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
Installing file.
PackageAdded: package:b4a.example
Copying updated assets files (2)
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 55 (Main)
java.lang.IndexOutOfBoundsException: Invalid index 12, size is 10
    at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
    at java.util.ArrayList.get(ArrayList.java:308)
    at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
    at b4a.example.main._button1_click(main.java:421)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
    at android.view.View.performClick(View.java:4848)
    at android.view.View$PerformClick.run(View.java:20262)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5627)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
** Activity (main) Pause, UserClosed = true **
 
Upvote 0

tpakis

Active Member
Licensed User
Longtime User
In the logs I see that when you try to set the edittext1 and edittext2 texts you want to get the elements 12 and 13 from the mylist but the mylist contains only 10 elements not 12 or 13 and that's why it crashes
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
The length of the list depends on the provider.
The example from this thread may help:
B4X:
If myList.Size >=14 Then
    gpsTimeTxt.Text = DateTime.Date(myList.Get(11)) & " " & DateTime.Time(myList.Get(11))
    gpsLatTxt.Text = NumberFormat(myList.Get(12), 0, 9)
    gpsLongTxt.Text = NumberFormat(myList.Get(13), 0, 9)
    gpsAccTxt.Text = NumberFormat(myList.Get(14), 0, 9)
Else
    If myList.Size >=9 Then
        passiveTimeTxt.Text = DateTime.Date(myList.Get(6)) & " " & DateTime.Time(myList.Get(6))
        passiveLatTxt.Text = NumberFormat(myList.Get(7), 0, 9)
        passiveLongTxt.Text = NumberFormat(myList.Get(8), 0, 9)
        passiveAccTxt.Text = NumberFormat(myList.Get(9), 0, 9)
    Else
        If myList.Size >=4 Then
            netTimeTxt.Text = DateTime.Date(myList.Get(1)) & " " & DateTime.Time(myList.Get(1))
            netLatTxt.Text = NumberFormat(myList.Get(2), 0, 9)
            netLongTxt.Text = NumberFormat(myList.Get(3), 0, 9)
            netAccTxt.Text = NumberFormat(myList.Get(4), 0, 9)
        Else
            Log("No Net location data available")
        End If
    End If
End If
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
@MaFu ... just a thought .. could not your code be streamlined to something similar ??
B4X:
Dim s As Int = mylist.Size
    If s => 4 Then
        gpsTimeTxt.Text = DateTime.Date(mylist.Get(s - 3)) & " " & DateTime.Time(mylist.Get(s-3))
        gpsLatTxt.Text = NumberFormat(mylist.Get(s - 2), 0, 9)
        gpsLongTxt.Text = NumberFormat(mylist.Get(s - 1), 0, 9)
        gpsAccTxt.Text = NumberFormat(mylist.Get(s), 0, 9)
    Else
         Log("No Net location data available")
    End If


Edit .. No it Can't o_O I just had a re-read and understand why .
I could not see .. my eye balls were in the way !:)
 
Last edited:
Upvote 0
Top