GPS not working in Async Task

前端 未结 3 436
北海茫月
北海茫月 2021-01-25 03:05

I have implemented a simple GPS program that fetches the co-ordinates and displays them on the screen. When I tried to improve on this design and implement an async task, the GP

3条回答
  •  心在旅途
    2021-01-25 03:42

    like many other things , gps listener can only be listened to by a loopy thread (like the ui thread) . the easiest thing to do would be to it via the ui thread .

    also , the gps listener isn't named like this for no reason . only when it gets a location (and that could take time) , it will call the method "onLocationChanged" . you don't need to have asyncTask for this , since all of the calls to "requestLocationUpdates" are asynchronous anyway...

提交回复
热议问题