我扩展了我之前的问题,我解决了这个问题,但我有一个新的类似错误。
我有以下活动
public class ActivityMatchesList extends FragmentActivity implements LoaderManager.LoaderCallbacks<Cursor> {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ListView lvLive = (ListView)findViewById(R.id.matchListList);
lvLive.setOnItemClickListener(OnItemClickListenerLive);
getSupportLoaderManager().initLoader(1, null, this);
getSupportLoaderManager().initLoader(2, null, this);
getSupportLoaderManager().initLoader(3, null, this);
}
private OnItemClickListener OnItemClickListenerLive = new OnItemClickListener(){
Intent i = new Intent(ActivityMatchesList.this, ActivityEvents.class);
finish();
startActivity(i);
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) { //FIXME: add switch for 3 loader
switch (id){
case 1:
CursorLoader cursorLoaderLive = new CursorLoader(this, uri1,null,null,null,null);
return cursorLoaderLive;
case 2:
CursorLoader cursorLoaderRankingLeague = new CursorLoader(this, uri1,null,null,null,null);
return cursorLoaderRankingLeague;
case 3:
CursorLoader cursorLoaderRankingLive = new CursorLoader(this, uri1,null,null,null,null);
return cursorLoaderRankingLive;
default:
return null;
}
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
switch (loader.getId()){
case 1:
Adapter1.swapCursor(cursor);
break;
case 2:
Adapter2.swapCursor(cursor);
break;
case 3:
Adapter3.swapCursor(cursor);
break;
}
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
switch (loader.getId()){
case 1:
Adapter1.swapCursor(null);
break;
case 2:
Adapter2.swapCursor(null);
break;
case 3:
Adapter3.swapCursor(null);
break;
}
}
}
使用 OnItemClickListener 我完成()此活动并开始一个新活动,当我完成新活动以返回此活动时,有时会出现以下错误
11-30 09:35:01.839: INFO/dalvikvm(321): Uncaught exception thrown by finalizer (will be discarded):
11-30 09:35:01.848: INFO/dalvikvm(321): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@43c6ab00 on MAIN_TABLE that has not been deactivated or closed
11-30 09:35:01.848: INFO/dalvikvm(321): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
11-30 09:35:01.848: INFO/dalvikvm(321): at dalvik.system.NativeStart.run(Native Method)
我无法找到原因,有人可以帮助我吗?
编辑:如果我只使用 1 个装载机,问题仍然存在。似乎随着活动完成,加载程序有时不会关闭光标,为什么?