在 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);
}
在调用的 Activity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......
......
Cursor tags;
db.open();
tags = db.getContactTags(contactID);
startManagingCursor(tags);
.......
.......
db.close();
}