Sub btnTrip_Click
' planTrip, this is the java code from the test programm
'
'void planTrip(Routeable destination,
' Trip.PlanListener PlanListener)
'
' Plan a trip from the current location To a destination. This call will switch the focus To the NavApp when the trip-planning Is started. The passed In listener Is only active Until the result of the call has been returned. Once a result has been returned the listener won't receive any more callbacks (but can be re-used).
'
' Parameters:
' destination - The Routeable destination To plan To.
' PlanListener - Trip.PlanListener To receive information about the result of the trip planning.
' Throws:
' java.lang.IllegalArgumentException - If any argument Is Null.
'here my code begins
'lat and lon are hard coded for tests (EPS)
Dim lat As Double = 47.4642
Dim lon As Double = 9.03826
'init API and error callback
Dim Factory As JavaObject
Factory.InitializeStatic("com.tomtom.navapp.NavAppClient.Factory")
Dim callback As Object = Factory.CreateEvent("com.tomtom.navapp.ErrorCallback", "NavError", Null)
Dim client As JavaObject = Factory.RunMethod("make", Array(GetContext, callback))
Dim RouteableDestination As JavaObject = client.RunMethod("makeRouteable", Array(lat, lon))
Dim TripManager As JavaObject = client.RunMethod("getTripManager",Null)
Dim PlanListener As JavaObject = TripManager.CreateEvent("com.tomtom.navapp.Trip.PlanListener", "ListenerTrip", Null)
' These calls all throw an exception as noted belowthe call
' TripManager.RunMethod("planTrip",Array(PlanListener))
' java.lang.RuntimeException: Method: planTrip not matched.
' TripManager.RunMethod("planTrip",Array(lat,lon))
' java.lang.RuntimeException: Method: planTrip not matched.
' TripManager.RunMethod("planTrip",Null)
' TripManager.RunMethod("planTrip",PlanListener)
' java.lang.IllegalArgumentException: argument 2 should have type java.lang.Object[], got $Proxy8
' TripManager.RunMethod("planTrip",Array(RouteableDestination))
' java.lang.RuntimeException: Method: planTrip not matched.
TripManager.RunMethod("planTrip",RouteableDestination)
'java.lang.ClassCastException: $Proxy7 cannot be cast to java.lang.Object[]
End Sub
Sub ListenerTrip_Event (MethodName As String, Args() As Object) As Object
Msgbox("TripListener"&MethodName,"")
End Sub