'Code module
#Region Project Attributes
#ApplicationLabel: B4i Example
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#Target: iPhone, iPad
#ATSEnabled: True
#MinVersion: 8
#PlistExtra:<key>NSLocationWhenInUseUsageDescription</key><string>Your location is used during search.</string>
#PlistExtra:<key>NSLocationUsageDescription</key><string>Your location is used during search.</string>
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private xui As XUI
Private loc As LocationManager
End Sub
Private Sub Application_Active
Dim lm As LocationManager
loc = lm
loc.Initialize("loc")
End Sub
Private Sub Application_Background
loc = Null
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.RootPanel.LoadLayout("Page1")
NavControl.ShowPage(Page1)
loc.Initialize("loc")
End Sub
Sub Step1
' Find our location
loc.Start(0)
End Sub
Sub loc_LocationChanged(NewLocation As Location)
' Got our GPS coordinates, now lets stop gps and save battery
loc.Stop
'' Do some search using the coordinates we got
End Sub
Sub Step2
loc.Stop ' Make sure gps is stopped
loc = Null ' lets try to destroy the LocationManager handle
Sleep(100) ' give the app a moment to maybe allow the gps to release?
'' In our search result we found something we like, lets navigate to it! (New York, NY in this case)
If App.CanOpenURL("comgooglemaps://?daddr=40.6976637,-74.119764") = True Then ' lets see if google maps app is installed (preferred)
App.OpenURL("comgooglemaps://?daddr=40.6976637,-74.119764") ' yes, lets show google maps
Else
App.OpenURL("http://maps.apple.com/?daddr=40.6976637,-74.119764") ' no google maps, lets load apple's default maps app
End If
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub