Unfortunately, I can't attach source code, but I will try to describe
the problem. I created a Fragment containing an instance of a class
extending MapView. The instance of this class is instantiated
programmatically, the constructor of the custom MapView calls the
MapView(Context c, String apiKey) constructor of the super class. When
starting the Activity containing the MapView (the Activity is a
MapActivity), the MapView gets displayed properly, but when I attempt
to change the orientation (configuration change), the instantiation of
the custom MapView fails with the following stacktrace:


07-13 16:51:41.270: ERROR/AndroidRuntime(20412): Caused by:
java.lang.NullPointerException
07-13 16:51:41.270: ERROR/AndroidRuntime(20412):     at
com.google.android.maps.MapActivity.setupMapView(MapActivity.java:400)
07-13 16:51:41.270: ERROR/AndroidRuntime(20412):     at
com.google.android.maps.MapView.<init>(MapView.java:289)
07-13 16:51:41.270: ERROR/AndroidRuntime(20412):     at
com.google.android.maps.MapView.<init>(MapView.java:235)
07-13 16:51:41.270: ERROR/AndroidRuntime(20412):     at
mypackage.MyCustomMapView.<init>(MyCustomMapView.java:36)

As one can see, the NullPointerException happens somewhere in the SDK.
Now,  I have tried to retain the instance of the Fragment using
fragment.setRetainInstance(true). This obviously stops the code
failing at this point, but the MapView remains black after the
orientation change has been finished. Calling invalidate() on the
MapView or any of its parent views does not change the situation. My
theory is that the MapView does not resume properly, but I am not sure
how to determine if that is the case. Any suggestions would be
appreciated (either on the NullPointerException or the black MapView
when setRetainInstance(true) is used).


Patrick

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to