我正在尝试使用此代码获取用户地理点
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
GeoPoint test = new GeoPoint((int)location.getLatitude()*1000000, (int)location.getAltitude()*1000000);
MapView mapview = (MapView) findViewById(R.id.mvmap);
MapController mapcontrol = mapview.getController();
mapcontrol.animateTo(test);
mapview.setStreetView(true);
mapview.setSatellite(true);
mapview.setBuiltInZoomControls(true);
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
};
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
但我收到一个这样的错误。
07-25 16:02:42.525: E/AndroidRuntime(7262): FATAL EXCEPTION: main
07-25 16:02:42.525: E/AndroidRuntime(7262): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.frux.kfcmobile/com.frux.kfcmobile.MapViewActivity}: java.lang.IllegalArgumentException: requested provider network doesn't exisit
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.os.Handler.dispatchMessage(Handler.java:99)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.os.Looper.loop(Looper.java:137)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-25 16:02:42.525: E/AndroidRuntime(7262): at java.lang.reflect.Method.invokeNative(Native Method)
07-25 16:02:42.525: E/AndroidRuntime(7262): at java.lang.reflect.Method.invoke(Method.java:511)
07-25 16:02:42.525: E/AndroidRuntime(7262): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-25 16:02:42.525: E/AndroidRuntime(7262): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-25 16:02:42.525: E/AndroidRuntime(7262): at dalvik.system.NativeStart.main(Native Method)
07-25 16:02:42.525: E/AndroidRuntime(7262): Caused by: java.lang.IllegalArgumentException: requested provider network doesn't exisit
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.os.Parcel.readException(Parcel.java:1429)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.os.Parcel.readException(Parcel.java:1379)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.location.LocationManager._requestLocationUpdates(LocationManager.java:660)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.location.LocationManager.requestLocationUpdates(LocationManager.java:482)
07-25 16:02:42.525: E/AndroidRuntime(7262): at com.frux.kfcmobile.MapViewActivity.onCreate(MapViewActivity.java:56)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.app.Activity.performCreate(Activity.java:5008)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-25 16:02:42.525: E/AndroidRuntime(7262): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-25 16:02:42.525: E/AndroidRuntime(7262): ... 11 more
任何人都可以找出导致错误的原因吗?