theophany77
Newbie
Hi,
On my Samsung S7 Edge, I have developed a ContentProvider for my suggestion search (my app is about songs and should return some song names after typing a few letters as a suggestion ; ex : “bri” should return “across the bridge”) but it fails like this under Android Studio
I have a very simple matrixcursor for the columns required by the search framework given there is only the mandatory " _id" column in it :
Here is the source code for some important lines and the query cursor
…
Even if I add another column (SUGGEST_COLUMN_TEXT_1), it fails the same way.
Do you have an idea ?
Why is the Getlong used for in the MatrixCursor ?
Thanks in advance.
Jean-michel, Nemours, France
PS : I have already posted that same question on "https://forums.bignerdranch.com/t/g...or-while-in-suggestion-search-framework/15653" but with no answer so far.
On my Samsung S7 Edge, I have developed a ContentProvider for my suggestion search (my app is about songs and should return some song names after typing a few letters as a suggestion ; ex : “bri” should return “across the bridge”) but it fails like this under Android Studio
--------- beginning of crash
2018-12-21 11:35:06.953 31905-31905/songs4heaven_p2.com.hfad.songs4heaven_p2 E/AndroidRuntime: FATAL EXCEPTION: main
Process: songs4heaven_p2.com.hfad.songs4heaven_p2, PID: 31905
java.lang.NumberFormatException: For input string: "glo"
at java.lang.Long.parseLong(Long.java:590)
at java.lang.Long.parseLong(Long.java:632)
at android.database.MatrixCursor.getLong(MatrixCursor.java:280)
2018-12-21 11:35:06.953 31905-31905/songs4heaven_p2.com.hfad.songs4heaven_p2 E/AndroidRuntime: FATAL EXCEPTION: main
Process: songs4heaven_p2.com.hfad.songs4heaven_p2, PID: 31905
java.lang.NumberFormatException: For input string: "glo"
at java.lang.Long.parseLong(Long.java:590)
at java.lang.Long.parseLong(Long.java:632)
at android.database.MatrixCursor.getLong(MatrixCursor.java:280)
I have a very simple matrixcursor for the columns required by the search framework given there is only the mandatory " _id" column in it :
- private static String matrixCursorColumns = {"_id"};
Here is the source code for some important lines and the query cursor
…
Code:
private static final int SEARCH_SUGGEST = 0;
private static final int SEARCH_SUGGESTIONS = 1;
private static final int SHORTCUT_REFRESH=1
…
private static final String AUTHORITY=“songs4heaven_p2.com.hfad.songs4heaven_p2.SearchContentProvider”;
…
static final Uri CONTENT_URI=Uri.parse( “content://”+AUTHORITY);
mUriMatcher = new UriMatcher( UriMatcher.NO_MATCH );
mUriMatcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, SEARCH_SUGGEST);
mUriMatcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + “/*”, SEARCH_SUGGEST);
…
public Cursor query(@NonNull Uri uri, [USER=1996173]@nullable[/USER] String projection,
[USER=1996173]@nullable[/USER] String selection,
[USER=1996173]@nullable[/USER] String selectionArgs,
[USER=1996173]@nullable[/USER] String sortOrder) {
String query = uri.getLastPathSegment().toLowerCase();
if (mUriMatcher.match(uri) == SEARCH_SUGGEST) {
Log.i("DEBUG_Sea_Cont_Prov", "query: if match");
//String query = uri.getLastPathSegment().toLowerCase();
return getSearchResultsCursor(query);
}
else {
Log.i("DEBUG_Sea_Cont_Prov", "query: else");
}
return null;
}
private MatrixCursor getSearchResultsCursor(String searchString){
searchResults.addRow( createRow1(searchString) );
}
}
}
Log.i("DEBUG_Sea_Cont_Prov", "getSearchResultsCursor: avant return: mRow:"+searchResults.toString());
//for (int i = 0; i < searchResults.getCount(); i++) {
// Log.i("DEBUG_Sea_Cont_Prov", "searchResults :"+searchResults.getString( i ));
//}
return searchResults; }
private Object[] createRow1(String query)
{
Log.i("DEBUG_Sea_Cont_Prov", "Entree dans createRow1 avec query:"+query);
//return columnValuesOfQuery(query,"query");
return columnValuesOfQuery(query);
}
private Object[] columnValuesOfQuery(String query)
{
Log.i("DEBUG_Sea_Cont_Prov", "Entree dans columnValuesOfQuery avec query:"+query);
return new String[]
{
query
};
}
Even if I add another column (SUGGEST_COLUMN_TEXT_1), it fails the same way.
Do you have an idea ?
Why is the Getlong used for in the MatrixCursor ?
Thanks in advance.
Jean-michel, Nemours, France
PS : I have already posted that same question on "https://forums.bignerdranch.com/t/g...or-while-in-suggestion-search-framework/15653" but with no answer so far.
Last edited by a moderator: