9

Wir haben vor kurzem unsere Anwendung gegen Android-API-Level 14 und 15 getestet. Wir begannen die Entwicklung Targeting minimal SKD Version 8 und ausschließlich Tablets (3.x).
Mit 2.x funktioniert alles gut, aber wenn die App auf einem 4.x-Droid ausgeführt wird, stürzt es an dem Punkt ab, an dem wir den Standort des Benutzers erhalten.IllegalArgumentException ausgelöst von requestLocationUpdate()

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) 
... 

Quelle:

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

Nach dem documentation ein IAE wird if provider or listener is null geworfen. Allerdings habe ich den Anbieter und den Hörer protokolliert. (Letzteres via toString()) und sie sind nicht null.

Kommend von this question fand ich eine open issue. Ich habe mich jedoch gefragt, wie Leute, die mehr Vertrauen in Eiscreme haben, die Koordinaten des Benutzers anfordern.
The tutorial Ich kenne den gleichen Ansatz wie oben beschrieben.

+1

Ich denke, man sollte den 'super()' den ersten Anruf Ihres 'onCreate() machen' ... Ich würde versuchen, diese :) –

+0

Ja, immer zu kämpfen, wo es zu setzen. Wie auch immer - das Problem besteht immer noch. – yoshi

+0

Das gleiche Problem haben. Ich frage mich, ob es ein Emulator-Problem oder auch ein echtes ICS-Gerät Problem ist –

Antwort

2
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 300000, 500, locationListener); 

in Ihrem Code verwenden diese LocationManager.NETWORK_PROVIDER beim Testen Sie, dass sicher, dass das Netzwerk, das Sie wie WIFI verwenden verfügbar ist oder Sie SIM-Karte in das Gerät eingesetzt und Netzwerk ist darauf zur Verfügung.

Sie können auch mit LocationManager.GPS_PROVIDER testen, aber darauf achten, vor dem Gebrauch, die GPS ON Geräte denken ist

+0

Ja WiFi ist verfügbar. (Ansonsten könnte ich das nicht posten: P). – yoshi