终结者抛出未捕获的异常(将被丢弃),Android

时间:2011-02-07 07:55:19

标签: android android-logcat

在logcat中我发现了这些消息,我的应用程序运行正常(没有错误/没有异常/和正确的结果),但为什么这些消息出现在log cat中。我关闭了所有游标。还有一件事,应用程序显示活动有点慢(我的logcat消息中列出了哪些活动),我认为生成这些日志消息需要花费时间。什么是解决方案。

I/ActivityManager(   63): Starting activity: Intent { cmp=com.pankaj.myapp/.SelectedContactActivity (has extras) }
    D/dalvikvm(  251): GC freed 2584 objects / 174064 bytes in 139ms
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d2c688 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d2bf58 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d2b5a8 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d29af0 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d293c0 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d28a28 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d26f70 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d26808 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d25e60 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d24310 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d23be0 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d23238 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d21780 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d21028 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d20688 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d1ebd0 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d1e480 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d1dae0 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d1bfa0 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d1b760 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/dalvikvm(  251): Uncaught exception thrown by finalizer (will be discarded):
    I/dalvikvm(  251): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43d1ac40 on contacts_tags that has not been deactivated or closed
    I/dalvikvm(  251):  at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
    I/dalvikvm(  251):  at dalvik.system.NativeStart.run(Native Method)
    I/ActivityManager(   63): Displayed activity com.pankaj.myapp/.SelectedContactActivity: 2245 ms (total 2245 ms)

来电者活动正在使用列表视图,并在点击列表项" SelectedContactActivity"活动电话。

来电者活动

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contacts_list_item);
        SimpleAdapter contactAdapter = getAdapter(); // This method returns SimpleAdapter object 
       // Bind to our new adapter.
       setListAdapter(contactAdapter);
    }

protected void onListItemClick(ListView l, View view, int position, long id) {
        super.onListItemClick(l, view, position, id);

        Intent intent = new Intent().setClass(this, AddModifyTag.class);
        intent.putExtra("_id",contactInfo.get("_id"));
        intent.putExtra("name", contactInfo.get("name"));
        intent.putExtra("number", contactInfo.get("number"));
        intent.putExtra("position", position);
        this.startActivityForResult(intent, EDIT_CONTACT_TAGS);
    }

在名为活动

public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
......
......
        Cursor tags;
        db.open();
        tags = db.getContactTags(contactID);
        startManagingCursor(tags);
        .......
        .......
        db.close();
}

1 个答案:

答案 0 :(得分:5)

我认为您收到此错误是因为您未关闭CursoronStop()中的onDestroy()。尝试关闭Cursor。您也可以startManagingCursor()使用Cursor,这将有助于您通过Android关闭光标。