草庐IT

getBestProvider

全部标签

android - 每次请求位置更新时都应该使用 android LocationManager.getBestProvider 吗?

我正在使用GoogleAPI和MapActivity、MapView等。当我需要获取当前位置时,我会在第一时间使用此代码:myLocationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);//SetsthecriteriaforafineandlowpowerproviderCriteriacrit=newCriteria();crit.setAccuracy(Criteria.ACCURACY_FINE);crit.setPowerRequirement(Criteria.POWER_LOW);

android - 即使启用了所有位置服务,Google 位置服务 getBestProvider 也会返回 null

即使map应用程序显示正确的位置,定位服务getBestProvider调用也返回null。FINE_LOCATION和COARSE_LOCATION的权限在list中。publicstaticLocationgetLocation(Contextcontext){LocationManagerlocationManager=(LocationManager)context.getSystemService(Context.LOCATION_SERVICE);Criteriacriteria=newCriteria();LocationmyLocation=locationManage

android - LocationManager 的 getBestProvider 返回 null

我有很多人报告了一个我无法重现的错误。当尝试打开MapView它报告getBestProvider正在返回null并且我知道这意味着没有找到满足我的标准的提供程序ACCURACY_COARSE因此,如果没有GPS,那么它应该依靠network或被动但显然不在那些用户设备上。如果GPS已关闭且没有网络连接,这意味着什么?我尝试关闭GPS并将手机置于飞行模式以尝试重现该问题,但我仍然能够在不强制关闭的情况下打开mapView,因此我不知道如何处理此问题。locationManager=(LocationManager)this.getSystemService(LOCATION_SERVI