vb.net - Accessing Location on Windows 10 in .net desktop application -


the company work has application used our field staff registers gps location periodically, wrote application windows 8 x86 using system.device.location geocoordinatewatcher class.

in windows 10 same code ceases function properly, geocoordinatewatcher.permission returns granted, yet continue receive unknown position each call. windows 8 , windows 10 tablets both have lte.

    public function getlocation() geocoordinate          dim geocoordinate geocoordinate          dim watcher geocoordinatewatcher          watcher = new geocoordinatewatcher(geopositionaccuracy.high)          watcher.trystart(false, timespan.frommilliseconds(15000))           logtofile("position permission: " & watcher.permission.tostring)          logtofile("watcher status: " & watcher.status.tostring)           geocoordinate = watcher.position.location           if geocoordinate.isunknown              logtofile("unknown")          else              logtofile(string.format("lat: {0}, long: {1}, h accuracy: {2}, v accuracy: {3}, crse: {4}, spd: {5}, alt: {6}", geocoordinate.latitude, geocoordinate.longitude, geocoordinate.horizontalaccuracy, geocoordinate.verticalaccuracy, geocoordinate.course, geocoordinate.speed, geocoordinate.altitude))           end if          return geocoordinate      end function 

our log file shows every call have permission granted, mix of status = nodata or initializing, , position unknown.

we notification on tablets application accessing location information, , can confirm gps indeed working built in maps application correctly shows current gps location.

does have suggestions else try troubleshoot happening?

after looking @ function assume not have handler actual get's called when position changes. event positionchanged event (please see here), fired when latitude or longitude of location data has changed.

i recommend changing declaration of watcher class level variable , making withevents. example...

 private withevents watcher geocoordinatewatcher 

now have access of other methods , functions class. event callback position changes this.

private sub watcher_positionchanged(byval sender object, byval e geopositionchangedeventargs(of geocoordinate))    'here have access latitude , longitude coordinates example...   'e.position.location.altitude etc...    end sub      

so wrapped ....

 private withevents watcher geocoordinatewatcher'declare outside of function....   public sub startlocation()          watcher = new geocoordinatewatcher(geopositionaccuracy.high)          addhandler watcher.positionchanged, addressof watcher_positionchanged          watcher.start(false, timespan.frommilliseconds(15000))  end sub   private sub watcher_positionchanged(byval sender object, byval e geopositionchangedeventargs(of geocoordinate))        logtofile("position permission: " & watcher.permission.tostring)        logtofile("watcher status: " & watcher.status.tostring)        e.* 'whatever need here...  end sub 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -