Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
382 views
in Technique[技术] by (71.8m points)

android - IllegalArgumentException thrown by requestLocationUpdate()

We recently tested our application against android API level 14 and 15. We started development targeting minimal SKD Version 8 and excluding tablets (3.x).
With 2.x everything works well but when running the app on a 4.x droid it crashes at the point we're obtaining user's location.

FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to create service  java.lang.IllegalArgumentException: provider=network  
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2263)  
at android.app.ActivityThread.access$1600(ActivityThread.java:123)  
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)  
at android.os.Handler.dispatchMessage(Handler.java:99)  
at android.os.Looper.loop(Looper.java:137)  
at android.app.ActivityThread.main(ActivityThread.java:4424)  
at java.lang.reflect.Method.invokeNative(Native Method)  
at java.lang.reflect.Method.invoke(Method.java:511)  
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)  
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)  
at dalvik.system.NativeStart.main(Native Method)  

Caused by: java.lang.IllegalArgumentException: provider=network  
at android.os.Parcel.readException(Parcel.java:1331)  
at android.os.Parcel.readException(Parcel.java:1281)  
at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646)  
at android.location.LocationManager._requestLocationUpdates(LocationManager.java:582)   
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:446)  
at package.name.LocationGetter.onCreate(LocationGetter.java:63)  
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2253)  
...

Source:

public void onCreate() {
  locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
  locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 300000, 500, locationListener);
  super.onCreate();
 }

According to the documentation an IAE is thrown if provider or listener is null. However I logged the provider and listener. (the latter via toString() ) and they're not null.

Coming from this question I found an open issue. However I was wondering how people that are more confident with ice cream sandwich request user's coordinates.
The tutorial I know of uses the same approach described above.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think this may be an issue with the Android Emulator at present.

See http://code.google.com/p/android/issues/detail?id=21237


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...