1

Im getting "unclosed cursor detected" when starting a MapActivity even in the most basic form:

protected void onCreate(Bundle icicle) {
    super.onCreate(icicle); // <--- The Exception occurs here
    setContentView(R.layout.layout_map);
}

After the exception, the map starts and it works perfectly, but that exception every time it starts the activity really bothers me.

The Exception:

04-04 12:02:22.858: W/Cursor(14122): Unclosed Cursor detected 04-04 12:02:22.866: W/Cursor(14122): at android.content.ContentResolver.query(ContentResolver.java:258) 04-04 12:02:22.866: W/Cursor(14122): at com.google.common.android.AndroidConfig.getSetting(Unknown Source) 04-04 12:02:22.866: W/Cursor(14122): at com.google.common.android.AndroidConfig.getDistributionChannelInternal(Unknown Source) 04-04 12:02:22.866: W/Cursor(14122): at com.google.common.Config.init(Unknown Source) 04-04 12:02:22.866: W/Cursor(14122): at com.google.common.android.AndroidConfig.(Unknown Source) 04-04 12:02:22.866: W/Cursor(14122): at com.google.common.android.AndroidConfig.(Unknown Source) 04-04 12:02:22.866: W/Cursor(14122): at com.google.android.maps.MapActivity.onCreate(MapActivity.java:405) 04-04 12:02:22.866: W/Cursor(14122): at com.myapp.activity.MyMapActivity.onCreate(MyMapActivity.java:25) 04-04 12:02:22.874: W/Cursor(14122): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 04-04 12:02:22.874: W/Cursor(14122): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717) 04-04 12:02:22.874: W/Cursor(14122): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769) 04-04 12:02:22.874: W/Cursor(14122): at android.app.ActivityThread.access$2500(ActivityThread.java:129) 04-04 12:02:22.874: W/Cursor(14122): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2117) 04-04 12:02:22.874: W/Cursor(14122): at android.os.Handler.dispatchMessage(Handler.java:99) 04-04 12:02:22.874: W/Cursor(14122): at android.os.Looper.loop(Looper.java:143) 04-04 12:02:22.874: W/Cursor(14122): at android.app.ActivityThread.main(ActivityThread.java:4717) 04-04 12:02:22.874: W/Cursor(14122): at java.lang.reflect.Method.invokeNative(Native Method) 04-04 12:02:22.882: W/Cursor(14122): at java.lang.reflect.Method.invoke(Method.java:521) 04-04 12:02:22.882: W/Cursor(14122): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) 04-04 12:02:22.882: W/Cursor(14122): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 04-04 12:02:22.882: W/Cursor(14122): at dalvik.system.NativeStart.main(Native Method)

I searched the web but found nothing... Extra info:

  • Im using Google API 2.2
  • Tested it on the device and on the AVD
  • Have other Map projects working with Google API 2.1 (Without that exception of course)
  • My AndroidManifest is not missing anything (hence the map starts and works after the exception is thrown)

Help is appreciated!

Edit:

I updated both Google API level 7 and 8 (the problem started on 8) now it happens on API level 7 too...

Hydrangea helped me notice that the Bundle variables name in my MapActivity (icicle) differs from the "standard" (savedInstanceState) maybe that has something to do with the problem?

Lisandro
  • 10,543
  • 1
  • 24
  • 29

2 Answers2

0

You need to close the cursor after you have the information from the database.

Example:

cursor.close();

Are you sure the problem doesn't exist from another class? Your code looks okay to me.

Aerial
  • 1,185
  • 4
  • 20
  • 42
0

I ran this on a 2.2 device, and didn't get any such error. Is something else happening in your Activity that might be causing it? Perhaps something in the bundle causing super.onCreate() to have issues?

public class HelloGoogleMapsActivity extends MapActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}
Turnsole
  • 3,422
  • 5
  • 30
  • 52
  • I realized somthing with your comment, when you override onCreate the bundle variable from your MapActivity class is savedInstanceState, while mine is protected void onCreate(Bundle **icicle**). Maybe a version problem??? – Lisandro Apr 05 '12 at 21:32
  • Hmm... was the variable named automatically? The name itself won't matter, but if there was an incomplete update of your SDK maybe the problem lies therein. – Turnsole Apr 09 '12 at 14:30
  • I realize the variable name it self makes no difference but what bothers me about it is that it is automatically generated based on the superclasses variable name. In other words, it seems as if my MapActivity differs from the standard MapActivity. (I uninstalled and reinstalled the version 8 of Google API and it made no difference) One more thing: I googled that variable name and in many cases it appears as "normal", but could not find anything about it giving this particular error. – Lisandro Apr 09 '12 at 22:52