Android Question problem accessing iterations of type

jamesnz

Active Member
Licensed User
Longtime User
edit - Has just occured to me I didn't post a question, just the code, apologies
so far I've made a http request to the mapquest server, parsed the results into
getdirections.maneuvers and made a type to hold the data I need.
xpoint should hold an index(int), lat,lng(doubles) and a voice(string)
I wan't to be able to retieve these values and can only do so in the first loop where I have commented ' this works perfectly, yet I cant retrieve these values in the loop afterwards, I get null pointer exceptions even if I manually ask for Log(xpoint(1).Index)

Code: Copy
sub Globals
Type instr(Index As Int, XLatitude As Double, XLongitude As Double, Voice As String)
    Dim xpoint(100) As instr
end sub

Code: Copy
Sub collectdata

Dim c As Int = 0
For i = 0 To getdirections.maneuvers.Size - 1
    c=c+1
    ListView1.AddSingleLine( getdirections.maneuvers.Get(i))
    Dim thisx= getdirections.maneuvers.Get(i)
    'Log ( thisx)
    Next
    directions .Initialize
  
    For Each colmaneuvers As Map In getdirections.maneuvers
        Dim signs As List            = colmaneuvers.Get("signs")
        Dim index As Int            = colmaneuvers.Get("index")
        xpoint(c).Index = index
        Dim maneuverNotes As List    = colmaneuvers.Get("maneuverNotes")
      
        Dim direction As Int        = colmaneuvers.Get("direction")
        Dim narrative As String        = colmaneuvers.Get("narrative")
        xpoint(c).Voice = narrative
        Dim iconUrl As String        = colmaneuvers.Get("iconUrl")
        Dim distance As Double        = colmaneuvers.Get("distance")
        Dim time As Int                = colmaneuvers.Get("time")
        Dim linkIds As List            = colmaneuvers.Get("linkIds")
        Dim streets As List            = colmaneuvers.Get("streets")
              
        For Each colstreets As String In streets
        Next
      
        'Dim attributes As Int            = colmaneuvers.Get("attributes")
        'Dim transportMode As String    = colmaneuvers.Get("transportMode")
        'Dim formattedTime As String    = colmaneuvers.Get("formattedTime")
        'Dim directionName As String    = colmaneuvers.Get("directionName")
        'Dim turnType As Int            = colmaneuvers.Get("turnType")
      
        Dim startPoint As Map            = colmaneuvers.Get("startPoint")
        Dim lng As Double                = startPoint.Get("lng")
        Dim lat As Double                = startPoint.Get("lat")
        Dim mapUrl As String            = colmaneuvers.Get("mapUrl")
      
      
        xpoint(c).XLatitude = lat
        xpoint(c).XLongitude= lng
      
'This logs perfectly
        Log (xpoint(c).Index )
        Log (xpoint(c).XLatitude )
        Log (xpoint(c).XLongitude )
        Log (xpoint(c).Voice )
      
    Next
  
    Log("length" & xpoint.length)
    Log (getdirections.maneuvers.Size)
  
    Dim p As Int
    For p = 0 To getdirections.maneuvers.Size - 1
    Log("p " & p )
' This does not ( null pointer exception) but values should work, even if I use 1, 2, 3 etc I get a null pointer exception
Log (xpoint(p).Voice)

    Next
  
End Sub
 
Last edited:
file attached, long press Btn Get directions
make address1 80 victoria street hamilton nz
use default addr2 ( or use 2 local examples)
press getstartlatlng ( under first edittext)
press get destlatlng ( under 2nd edittext)
Then - press Button get directions
wait for debugger to display route
then click Btn Back ( my back button, not the hardware)
when back in screen 1, press button collect data

cheers, appreciate you having a look at it :)
james
 

Attachments

Upvote 0
Back
Top