The handler of my activity in the adapter and the call to runQuery in the filter make a call to startManagingCursor in Activity when calling runQuery. This is not ideal, because the background thread calls startManagingCursor, and there can also be many cursors that remain open until the activity is destroyed.
I added the following to my adapter, which has an Activity handle that it uses in
@Override public void changeCursor(Cursor newCursor) { Cursor oldCursor = getCursor(); super.changeCursor(newCursor); if(oldCursor != null && oldCursor != newCursor) {
This ensures that the current cursor used by the adapter is also controlled by the action. When the cursor is closed by adapter management, the action is deleted. The last cursor held by the adapter will be closed by activity while it is controlled by the action.
source share