0

我启动了一项服务并尝试使用 requestLocationUpdates,但由于存在 NULLpointerException,该应用程序失败了。

4

2 回答 2

1

好像你没有初始化locationManager它刚刚声明的。

于 2013-03-06T07:22:06.347 回答
0

NullPointerException 的原因

您没有初始化 locationManger。

以这种方式初始化。

locationManager = (LocationManager) this.getSystemService(LOCATION_SERVICE);
Location myCurrentLocation = locationManager.getLastKnownLocation(getBestProvider());
于 2013-03-06T07:21:35.357 回答