geeksville / Gaggle

An Android application for glider pilots
http://groups.google.com/group/gaggle-users/
33 stars 16 forks source link

Can't open map tab #52

Closed dkm closed 3 years ago

dkm commented 12 years ago

I'm using latest source (not the apk from the market) on ICS (4.0.3).

When switching to the map tab, Gaggle closes. Logcat gives the following trace:

02-14 13:21:45.761: W/dalvikvm(6138): threadid=1: thread exiting with uncaught exception (group=0x40a4a1f8)
02-14 13:21:45.839: E/AndroidRuntime(6138): FATAL EXCEPTION: main
02-14 13:21:45.839: E/AndroidRuntime(6138): java.lang.RuntimeException: Unable to resume activity {com.geeksville.gaggle/com.geeksville.gaggle.FlyMapActivity}: java.lang.IllegalArgumentException: provider=network
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2444)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:146)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:682)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.widget.TabHost.setCurrentTab(TabHost.java:346)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:150)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:540)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.view.View.performClick(View.java:3511)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.view.View$PerformClick.run(View.java:14105)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.os.Handler.handleCallback(Handler.java:605)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.os.Looper.loop(Looper.java:137)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.app.ActivityThread.main(ActivityThread.java:4424)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at java.lang.reflect.Method.invokeNative(Native Method)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at java.lang.reflect.Method.invoke(Method.java:511)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at dalvik.system.NativeStart.main(Native Method)
02-14 13:21:45.839: E/AndroidRuntime(6138): Caused by: java.lang.IllegalArgumentException: provider=network
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.os.Parcel.readException(Parcel.java:1331)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.os.Parcel.readException(Parcel.java:1281)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:655)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.location.LocationManager._requestLocationUpdates(LocationManager.java:590)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.location.LocationManager.requestLocationUpdates(LocationManager.java:454)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at org.andnav.osm.views.overlay.MyLocationOverlay.enableMyLocation(MyLocationOverlay.java:411)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at com.geeksville.maps.GeeksvilleMapActivity.onResume(GeeksvilleMapActivity.java:280)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at com.geeksville.gaggle.FlyMapActivity.onResume(FlyMapActivity.java:261)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.app.Activity.performResume(Activity.java:4539)
02-14 13:21:45.839: E/AndroidRuntime(6138):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
02-14 13:21:45.839: E/AndroidRuntime(6138):     ... 17 more

I'm trying to debug that, but as this is my first android experience, I'm not very efficient :(

dkm commented 12 years ago

The problem comes from andnav/osmdroid that tries to enable some location provider without first checking that it is enabled. The code in MyLocationOverlay should look like:

if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
                    mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, XXX, YYY, myLocationOverlay);

I was about to send a patch, but it looks like the code has changed a lot and I guess that this bug has been fixed now (the requestLocationUpdates are conditionned by the provider being enabled...).

Is there any plan on porting Gaggle to latest osmdroid ?

dkm commented 12 years ago

BTW, I'm trying to port Gaggle code to latest osmdroid. There a bunch of API changes, but if the expected behavior of the API hasn't changed, I should get something soon.

dkm commented 12 years ago

Ok, it compiles and runs mostly. I still have to review all systematic changes I've made and some piece that I commented out.

Would this be any useful for Gaggle ? I'll commit this in my fork, but won't bother that much if you have some private dev that will render my work useless if you publish it someday :)

dkm commented 12 years ago

You can see in my fork how I get latest osmdroid to work with gaggle. There are still some method that I should take care :) But it looks like it works