Share My Creation GPS Example

Do not use this program it is a very old one which was released before the GoogleMaps library was released.
Many things have changed since the release of this program and it does no more work as expected.
I have not updated it to satisfy the new requirements of Google which have become more and more restrictive.

Here is a GPS Example program with following functions:
  • Connect the GPS
  • Get and display GPS information
  • Save a GPS path (program internal GPP format and Google Earth KML format)
  • Display the available satellites
  • Display Google maps
  • Display a GPS path on the map
  • Shows current GPS position on the map
Google map functions, user settable :
  • Display zoom control
  • Display scale control
  • Display a path
  • Display markers
  • Move a marker
  • Display coordinates (touch the screen)
  • Move the map / Display coordinates (touch the screen and move)
Some special features:
  • Table with first column always visible. Image GPS_3.
  • Touching a button changes it's color and shows a tooltip on top of the screen. Releasing it insides the button area executes the function and hides the tooltip. Releasing outsides the butoon area does not execute the function and hides the tooltip. This allows to check a button function without executing it. Image GPS_4
  • Touching some buttons displays 'subbuttons' to select other setup parameters more easily rather than doing it in the setup screen. Image GPS_5
Comments on the images:
  • GPS_1 Display of a GPS path with polyline and markers
  • GPS_2 Display of current GPS data with the position on the map
  • GPS_3 Display of GPS path data in a table
  • GPS_4 Main screen, display of a tooltip, just touched the PATH button before releasing it
  • GPS_5 Display of 'subbuttons' to select setup parameters
  • GPS_6 Display og Satellites data
  • GPS_7 Setup screen
  • GPS_8 Save screen with one button foe each file format
  • GPS_9 Shows InfoWindow
It is designed for smartphones and does work only in portrait mode.

The program needs following additional libraries:
- ByteConverter
- Dialogs
- RandomAccessFile
- WebViewExtras
- ScrollView2D

Thank's to warwound for the WebViewExtras library, that allowed adding events to the GoogleMaps WebView.

The programs functionalities are explained in the Basic4Android User's Guide and some code is also explained.
If there are some code parts you would like having explained in the Basic4Android User's Guide post the request in this thread.

Best regards.

EDIT: 2011.12.20 version 1.1
Updated the source code after the bug reports.

EDIT: 2011.12.21 version 1.2
Added the maptype_changed event, problem reported by dlfallen in post#21

EDIT: 2011.12.22 version 1.3
Changed the zoom calculation
Added MapTypeControlID choice
Added MapZoomControlStyle choice

EDIT: 2011.12.23 version 1.4
Amended the problems reported by dlfallen

EDIT: 2011.12.27 version 1.5
Added saving of a GPS path in Google Earth KML format.
Removed the short help file, the help is in the Beginner's Guide.

EDIT: 2011.12.28 version 1.51
Amended bug reported by timo in post #37

EDIT: 2012.02.06 version 1.55
Amended bug report by msains in post #56

EDIT: 2012.02.06 version 1.56
Amended bug report by alfcen in post #59

EDIT: 2012.02.08 version 1.60
Amended bug report by Andras in post #64

EDIT: 2012.06.02 version 1.70
Added most of Barry Sumpters' wishes
Amended input from Filippo (German forum)
Added an InfoWindow for the first marker, when clicking on the first Marker an InfoWindoe is displayed.

EDIT: 2012.06.12 version 1.80

Added a filter to remove close locations.
Improved some function and removed some bugs.

EDIT: 2012.10.09 version 2.00
Updated for tablets.
Works only in portrait on phones and both orientations on tablets.
Needs Basic4Android version 2.2 (uses AutoScale)

EDIT: 2013.03.06 version 2.1
Amended error reported in post #142.

EDIT: 2014.08.09 version 2.2
Added altitude above sea level post #175

EDIT: 2015.04.17 version 2.3
Amended error reported in post #179
Amended some minor bugs

EDIT 2018.02.15 version 2.6
Removed DoEvents
Replaced File.DirRootExternal by GetSafeDirDefaultExternal.
 

Attachments

  • GPS_1.jpg
    GPS_1.jpg
    62.1 KB · Views: 49,916
  • GPS_2.jpg
    GPS_2.jpg
    61.6 KB · Views: 4,548
  • GPS_3.jpg
    GPS_3.jpg
    74.8 KB · Views: 48,829
  • GPS_4.jpg
    GPS_4.jpg
    46.7 KB · Views: 3,996
  • GPS_5.jpg
    GPS_5.jpg
    66.1 KB · Views: 4,073
  • GPS_6.jpg
    GPS_6.jpg
    33.9 KB · Views: 3,872
  • GPS_7.jpg
    GPS_7.jpg
    42.3 KB · Views: 4,108
  • GPS_8.jpg
    GPS_8.jpg
    33.1 KB · Views: 3,706
  • GPS_9.jpg
    GPS_9.jpg
    52.8 KB · Views: 3,994
  • GPSExampleV2_6.zip
    134.5 KB · Views: 2,260
Last edited:

Roger Daley

Well-Known Member
Licensed User
Longtime User
Sorry Klaus,

Same problem. Debug screen print attached.
It appears that even with GPS1 is enabled, with no GPS signal penetrating to my study there is no data in vals(9).

Regards Roger

PS It works fine if I go outside.

Debug.jpg
 

klaus

Expert
Licensed User
Longtime User
Unfortunately, I hadn't tested it.
Use this code instead:
B4X:
Sub GPS1_NMEA (TimeStamp As Long, Sentence As String)
    If Sentence.SubString2(0, 6) = "$GPGGA" Then
        Dim vals() As String
        vals = Regex.Split(",", Sentence)
        If IsNumber(vals(9)) Then
            GPSAltitudeSeaLevel = vals(9)
        End If
    End If
End Sub
 

willk

Member
Licensed User
Hi Klaus,

Thank you very much for this example of GPS.
I have a problem where it compling :
<<
AAPT path: C:\Program Files\Android\android-sdk\tools\..\build-tools\21.0.0\aapt.exe
Exit code:-1073741819 >>

Can you help me ?

Thank you

William (French)
 

klaus

Expert
Licensed User
Longtime User
Do you get any error when you compile ?
If yes, can you send the full error message from the Logs ?
What Android versions have you installed ?
Habe you installed the Android SDK Build-tools for your version of Android ?

Est-ce que tu recois un message d'erreur ?
Si oui, peux-tu envoyer le message complet dans le Log.
Quelles versions d'Android as-tu installé ?
Est-ce que tu as installé Android SDK Build-tools pour ta version d'Android ?

upload_2016-8-4_9-20-56.png
 

Attachments

  • upload_2016-8-4_9-19-56.png
    upload_2016-8-4_9-19-56.png
    26.5 KB · Views: 473

willk

Member
Licensed User
Do you get any error when you compile ?
If yes, can you send the full error message from the Logs ?
What Android versions have you installed ?
Habe you installed the Android SDK Build-tools for your version of Android ?

Est-ce que tu recois un message d'erreur ?
Si oui, peux-tu envoyer le message complet dans le Log.
Quelles versions d'Android as-tu installé ?
Est-ce que tu as installé Android SDK Build-tools pour ta version d'Android ?

View attachment 46652

Bonjour Klaus,

merci pour ta réponse si rapide.
Le message que j'ai posté comportait une erreur à la compilation due à un programme non trouvé dans l'arborescence d'Android SDK.
Ce message est indiqué dans le message que j'ai posté hier.

Pour ma part, j'ai téléchargé et réinstallé Android SDK et je n'ai plus d'erreur.

Merci encore et bravo pour cette belle application.

William.
 

willk

Member
Licensed User
Bonjour Klaus,

merci pour ta réponse si rapide.
Le message que j'ai posté comportait une erreur à la compilation due à un programme non trouvé dans l'arborescence d'Android SDK.
Ce message est indiqué dans le message que j'ai posté hier.

Pour ma part, j'ai téléchargé et réinstallé Android SDK et je n'ai plus d'erreur.

Merci encore et bravo pour cette belle application.

William.

Message d'erreur à la compilation :
<<AAPT path: C:\Program Files\Android\android-sdk\tools\..\build-tools\21.0.0\aapt.exe
Exit code:-1073741819>>
 

Rusty

Well-Known Member
Licensed User
Longtime User
Hi Klaus,
I'm trying to compile your GPSExample onto my Samsung S7 device.
I'm getting the following error:
Failure [INSTALL_FAILED_CONTAINER_ERROR]
Any advice on what might be causing this?
Thanks,
Rusty
 

klaus

Expert
Licensed User
Longtime User
I just retried the version from the forum and it works on my Samsung Galaxy S6.

DO you have an older version on the device?
If yes, uninstall it and reinstall it.

Did you test it in release mode?
Do you get an error message in the Logs when running in Debug mode?

Have you tried to put a break point at the beginning of the code and go through the program step by step?
 

Rusty

Well-Known Member
Licensed User
Longtime User
Hi Klaus,
It compiles but won't load in Debug, Release or Release Obfuscated. In all cases I get:
upload_2017-1-15_14-28-17.png


So it is not possible to put a breakpoint within.
I've checked for a previously installed or similar named app and none exist.
It DOES install and run on my Asus 10" tablet running 4.4.2 Kitkat

Can this be a manifest issue or SDK?
BTW my S7 is running 6.0.1 Marshmallow

Rusty
 

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks to both of you :)
(sorry for the image post, Erel)
I re-installed the Android SDK and no difference, same error.
I then changed the #CanInstallToExternalStorage to False and it worked!
Thanks for the help.
Regards,
Rusty
 

JMW

Member
Licensed User
Longtime User
I am trying to install this on my phone and am getting an error:
B4X:
** Activity (main) Create, isFirst = true **
Error occurred on line: 12 (GPSModule)
java.nio.BufferUnderflowException
    at java.nio.DirectByteBuffer.getInt(DirectByteBuffer.java:230)
    at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadInt(RandomAccessFile.java:137)
    at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readHelper(RandomAccessFile.java:406)
    at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadObject(RandomAccessFile.java:395)
    at B4A.GPSExample.gpsmodule._loadpath(gpsmodule.java:41)
    at B4A.GPSExample.main._activity_create(main.java:710)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    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 anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at B4A.GPSExample.main.afterFirstLayout(main.java:102)
    at B4A.GPSExample.main.access$000(main.java:17)
    at B4A.GPSExample.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:746)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
** Activity (main) Resume **
Just learning B4A.
 

klaus

Expert
Licensed User
Longtime User
In the Files folder of the project replace:
B4X:
If File.Exists(File.DirAssets,"Test1.GPP") Then
    File.Copy(File.DirAssets, "Test1.GPP", GPSDir,"Test1.GPP")
End If
If File.Exists(File.DirAssets,"Test2.GPP") Then
    File.Copy(File.DirAssets, "Test2.GPP", GPSDir,"Test2.GPP")
End If

by
B4X:
If File.Exists(File.DirAssets,"test1.gpp") Then
    File.Copy(File.DirAssets, "test1.gpp", GPSDir,"test1.gpp")
End If
If File.Exists(File.DirAssets,"test2.gpp") Then
    File.Copy(File.DirAssets, "test2.gpp", GPSDir,"test2.gpp")
End If
Attached a new version.
 

Attachments

  • GPSExampleV2_4.zip
    133.7 KB · Views: 588

JMW

Member
Licensed User
Longtime User
Thank you Klaus. That fixed it, and I learned something important.
 

Similar Threads

  • Question
Android Question GPS location
Replies
1
Views
1K
Replies
5
Views
1K
Replies
5
Views
1K
Replies
1
Views
2K
Top