I am trying to populate results for the global search box. I can currently type in the search box and have my debugger stop in query() just as I would expect. Just as a test I am populating a MatrixCursor manually to return from the query() method. Here is the test code...
public class GlobalSearchProvider extends ContentProvider { private static final String[] SEARCH_CURSOR_COLUMNS = new String[] {"_ID","SUGGEST_COLUMN_TEXT_1","SUGGEST_COLUMN_TEXT_2","SUGGEST_COLUMN_ICON_1","SUGGEST_COLUMN_INTENT_EXTRA_DATA"}; @Override public Cursor query( Uri uri, String[] columns, String where, String[] whereArgs, String sortOrder ) { switch( uriMatcher.match( uri ) ) { case GLOBAL_SEARCH_SUGGESTION_CODE: { return getSuggestionTest( whereArgs[0] ); } default: throw new IllegalArgumentException( "Unknown Uri: " + uri ); } } private Cursor getSuggestionTest( String searchTerm ) { MatrixCursor cursor = new MatrixCursor( SEARCH_CURSOR_COLUMNS ); if( searchTerm == null || searchTerm.length() == 0 ) return cursor; ArrayList<Object> columnValues = new ArrayList<Object>(); columnValues.add( 0 ); // _ID columnValues.add( "Poofy and the Buttons"); columnValues.add( searchTerm ); columnValues.add( null ); columnValues.add( 0 ); cursor.addRow( columnValues ); ArrayList<Object> columnValues2 = new ArrayList<Object>(); columnValues2.add( 1 ); // _ID columnValues2.add( "Joe Mama"); columnValues2.add( searchTerm ); columnValues2.add( null ); columnValues2.add( 0 ); cursor.addRow( columnValues2 ); int nr = cursor.getCount(); return cursor; } } Here is the searchable.xml <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="@string/search_label" android:hint="@string/search_hint" android:searchSuggestAuthority="com.poofy.GlobalSearchProvider" android:searchSuggestThreshold="1" android:includeInGlobalSearch="true" android:searchSuggestIntentAction="android.Intent.action.VIEW"> </searchable> And in the manifest <provider android:name=".GlobalSearchProvider" android:authorities="com.poofy.GlobalSearchProvider" /> Very simple. It returns a cursor with two elements. The debugger shows it working nicely... until you see that the search list actually contains only one result with no text in it! Yes, I have enabled search to get results from my app (or it would have never stopped the debugger). Its as if the contents of the MatrixCursor is not recognized by the system. (I have to use a MatrixCursor because my results do not come from a database.) Any idea what might be happening here? Thanks -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en