Android Emulator:位置提供程序处的非法参数异常Null
该应用程序将在我的真实设备上正常运行,但在 模拟器,它立即崩溃,我收到一条错误消息,指出GPS坐标为空。即使在打开DDMS,运行应用程序,然后发送坐标并尝试登录(其中将调用onCreate方法查找GPS)之后,它仍然注意到空错误(如下) 我创建的所有模拟器都支持GPS,但错误仍然存在。首先需要GPS的onCreate的代码如下:Android Emulator:位置提供程序处的非法参数异常Null,android,android-emulator,gps,illegalargumentexception,Android,Android Emulator,Gps,Illegalargumentexception,该应用程序将在我的真实设备上正常运行,但在 模拟器,它立即崩溃,我收到一条错误消息,指出GPS坐标为空。即使在打开DDMS,运行应用程序,然后发送坐标并尝试登录(其中将调用onCreate方法查找GPS)之后,它仍然注意到空错误(如下) 我创建的所有模拟器都支持GPS,但错误仍然存在。首先需要GPS的onCreate的代码如下: // Ensuring a location, loop till find it do { // Get the location manager
// Ensuring a location, loop till find it
do {
// Get the location manager
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// Define the criteria how to select the location provider -> use
// default
Criteria criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, false);
Location location = locationManager.getLastKnownLocation(provider);
// Just test displaying
lat = (float) (location.getLatitude());
lng = (float) (location.getLongitude());
} while (lat == 0.0);
具体的错误消息是:
java.lang.IllegalArgumentException: invalid provider: null at android.location.LocationManager.checkProvider(LocationManager.java:1623)
在android emulator上,您可以从
locationManager.getBestProvider(标准,false)获得null
提供程序代码>
查看此帖子: