Android GoogleMapV2当前位置无效

时间:2015-04-24 12:41:16

标签: android nullpointerexception

我试图使用Android谷歌地图v2获取当前位置。我的应用程序正在崩溃...我的代码和logcat如下。我搜索了很多来获取它。请摆脱它。

UPDATE tbl_DevicePrices
SET DP.price = case when DP.condition = 'Fair' then xl.fair
                    when DP.condition = 'GOOD' then xl.Good
                    when DP.condition = 'Mint' then xl.Mint
                    when DP.condition = 'new' then xl.new
                    when DP.condition = 'Poor' then xl.Poor
                    when DP.condition = 'Broken' then xl.Broken
                    else dp.Price end
FROM tbl_DevicePrices DP
INNER JOIN ExcelUpload xl
 on xl.deviceID = DP.DeviceID

我的日志猫是如下

setContentView(R.layout.location_map);
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
googleMap = fm.getMap();
googleMap.setMyLocationEnabled(true);
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String bestProvider = locationManager.getBestProvider(criteria, true);
Location location = locationManager.getLastKnownLocation(bestProvider);
double currentlatitude = location.getLatitude();
double currentlongitude = location.getLongitude();
locationManager.requestLocationUpdates(bestProvider, 20000, 0, this);
CURRENT_LOCATION = new LatLng(currentlatitude, currentlongitude);

1 个答案:

答案 0 :(得分:0)

这显然与Google Map v2 API无关......

  

RuntimeException:无法启动活动ComponentInfo {com.ambilobes.flowbornprivilege / com.ambilobes.flowbornprivilege.LocationFinder}:java.lang.NullPointerException

你得到了自己NullPointerException。让我们看看它:

  

引起:java.lang.NullPointerException

     

at com.ambilobes.flowbornprivilege.LocationFinder.onCreate(LocationFinder.java:61)

查看 LocationFinder.java:61 ,您就会发现问题。