@Override public Cursor runQueryOnBackgroundThread(CharSequence constraint){
  if (DBG)   Log.d(LOG_TAG,"runQueryOnBackgroundThread(" + constraint + ")");
  String query=(constraint == null) ? "" : constraint.toString();
  Cursor cursor=null;
  if (mSearchView.getVisibility() != View.VISIBLE || mSearchView.getWindowVisibility() != View.VISIBLE) {
    return null;
  }
  try {
    cursor=getSuggestions(query,QUERY_LIMIT);
    if (cursor != null) {
      cursor.getCount();
      return cursor;
    }
  }
 catch (  RuntimeException e) {
    Log.w(LOG_TAG,"Search suggestions query threw an exception.",e);
  }
  return null;
}

@ Override public Cursor runQueryOnBackgroundThread ( CharSequence constraint ) { if ( DBG ) Log . d ( LOG_TAG , "runQueryOnBackgroundThread(" + constraint + ")" ) ; String query = ( constraint == null ) ? "" : constraint . toString ( ) ; Cursor cursor = null ; if ( mSearchView . getVisibility ( ) != View . VISIBLE || mSearchView . getWindowVisibility ( ) != View . VISIBLE ) { return null ; } try { cursor = getSuggestions ( query , QUERY_LIMIT ) ; if ( cursor != null ) { cursor . getCount ( ) ; return cursor ; } } catch ( RuntimeException e ) { Log . w ( LOG_TAG , "Search suggestions query threw an exception." , e ) ; } return null ; }
use the search suggestions provider to obtain a live cursor . this will be called in a worker thread , so it ' s ok if the query is slow ( e . g . round trip for suggestions ) . the results will be processed in the ui thread and changecursor ( ) will be called .
