Sub GeneraRuta()
wm = ""
Dim MiUrl As String
Dim request As HttpRequest
Dim MiTaskId As String
Dim MiFechaHora, MiFecha As String
DateTime.DateFormat = "yyyy-MM-dd HH:mm:ss"
MiFechaHora = DateTime.Now
If CheckConnection Then
url = "http://maps.googleapis.com/maps/api/directions/json?origin=48.267058,16.425503&destination=48.13769992466281,16.324900053441525&sensor=false&language=de"
MiUrl = "http://maps.googleapis.com/maps/api/directions/xml?origin=40.38404,-3.69250&destination=39.50758,-3.52579&sensor=False&language=es"
' MiUrl = MiUrl.Replace("LATI", Latitud)
' MiUrl = MiUrl.Replace("LONG", Longitud)
request.InitializeGet(MiUrl)
request.Timeout = 10000 'set timeout to 10 seconds
If HttpClient1.Execute(request, MiFechaHora) = False Then
Return 'Will be false if there is already a running task (with the same id).
Else
'HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
End If
ProgressDialogShow("Calling address server...")
End If
End Sub
Sub HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim SQL1 As SQL
Dim Query As String
ProgressDialogHide
Dim result As InputStream
Try
result = Response.GetInputStream 'GetString("UTF8") 'Convert the response to a string
Catch
Log("Error ::: Response.GetInputStream ")
End Try
'--------------------------------------------------------------------------------------------------------------
Response.GetAsynchronously("Response", File.OpenOutput(Main.DirCcDta, TaskId & "wm.txt", False), True, TaskId)
'--------------------------------------------------------------------------------------------------------------
Log("ResponseSuccess")
Log(result)
MiListaPoly.Initialize
Parser.Parse(result, "Parser")
MiListaPoly = MiListaPoly
wm = ""
result.Close
End Sub
Sub HttpClient1_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
Log(Reason)
Log(StatusCode)
ProgressDialogHide
If StatusCode = -1 Then msg = "The phone is offline"
ToastMessageShow (Reason, True)
End Sub
Sub Response_StreamFinish (Success As Boolean, TaskId As Int)
Dim another_buffer () As Byte
another_buffer = my_buffer.ToBytesArray
Log (BytesToString(another_buffer, 0, another_buffer.Length, "UTF8"))
End Sub
Sub Parser_StartElement (Uri As String, Name As String, Attributes As Attributes)
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
'http://maps.google.com/maps/api/geocode/xml?latlng=40.47981437,-3.37913171&sensor=false
If Name = "points" Then
If wm.Length > 0 Then Return
wm = "" & Text.ToString & CRLF
MapsDecodePolyline(Text.ToString, MiListaPoly)
wm = ""
End If
End Sub
Sub CheckConnection As Boolean
' If MyLan.IsInitialized Then WifiOn = CheckWiFi
' CheckConnection
Dim p AsPhone
If (p.GetDataState == "CONNECTED") Then
ReturnTrue
EndIf
If (p.GetSettings ("wifi_on") == 1) Then
ReturnTrue
EndIf
If (p.GetDataState == "DISCONNECTED") Then
ReturnFalse
EndIf
If (p.GetDataState == "SUSPENDED") Then
ReturnFalse
EndIf
End Sub