草庐IT

bestLocation

全部标签

android - 我当前的位置总是返回 null。我怎样才能解决这个问题?

我正在尝试为一个android项目查找我当前的位置。加载应用程序时,我的当前位置始终为空。我已经在list等中设置了权限。当我找到当前位置时,我打算使用坐标来查找到map上其他位置的距离。我的代码fragment如下。为什么我总是得到一个空值?locMan=(LocationManager)getSystemService(Context.LOCATION_SERVICE);Criteriacrit=newCriteria();towers=locMan.getBestProvider(crit,false);location=locMan.getLastKnownLocation(t

android - 我当前的位置总是返回 null。我怎样才能解决这个问题?

我正在尝试为一个android项目查找我当前的位置。加载应用程序时,我的当前位置始终为空。我已经在list等中设置了权限。当我找到当前位置时,我打算使用坐标来查找到map上其他位置的距离。我的代码fragment如下。为什么我总是得到一个空值?locMan=(LocationManager)getSystemService(Context.LOCATION_SERVICE);Criteriacrit=newCriteria();towers=locMan.getBestProvider(crit,false);location=locMan.getLastKnownLocation(t