Android Google Maps API OnLocationChanged only called once

主宰稳场 提交于 2019-12-06 13:37:48

I think you need to use the Location Manager. There is a good tutorial here.

What is say's on the website is that you need to add the following:

LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 

locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER,
                2000,   
                10, this);

the first parameters is the provider you are using (in this case the GPS Provider). The second parameter (2000) is the minimum time in milliseconds between each update. The third parameter (10) is the minimum distance. The last parameters is your LocationListener (this).

It is also a good idea to implement onProviderDisabled in case the user has his GPS turned off.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!