Android的定位服务:我可以用一个位置监听器GPS和网络位置?位置、监听器、可以用、网络

2023-09-06 16:22:08 作者:煙雨過客

我是否注册为网络位置和GPS定位单一LocationListener的对象还是我为每一个单独的?

Do I register a single locationlistener object for both network location and gps location or do I create a separate one for each?

推荐答案

您可以使用相同的监听器两种。

You can use the same listener for both.

当你得到 onLocationChanged() onStatusChanged()回调可以检查传入的参数(位置或供应商),以确定回调的来源(即:网络或GPS)

When you get the onLocationChanged() or onStatusChanged() callback you can examine the incoming parameters (location or provider) to determine the source of the callback (ie: Network or GPS).