android - How create SearchRecentSuggestionsProvider? -


my code:

provider description:

   <provider android:name=".searchprovider.mysuggestionprovider"           android:authorities="com.example.music.store.searchprovider.mysuggestionprovider"           android:exported="false" ></provider> 

java:

package com.example.music.store.searchprovider;  import android.content.searchrecentsuggestionsprovider; import android.database.cursor; import android.database.mergecursor; import android.net.uri; import android.util.log;  public class mysuggestionprovider extends searchrecentsuggestionsprovider {     public final static string authority = "com.example.music.store.searchprovider.mysuggestionprovider";     public final static int mode = database_mode_2lines | database_mode_queries;      public mysuggestionprovider() {         super();         setupsuggestions(authority, mode);     }      @override     public cursor query(uri uri, string[] projection, string sel,             string[] selargs, string sortorder) {         cursor recentcursor = super.query(uri, projection, sel, selargs,                 sortorder);         cursor[] cursors = new cursor[] { recentcursor, null};          log.e("cur", cursors[0].tostring());         return new mergecursor(cursors);         //retrieves custom suggestion cursor , returns     } }

but when run don't see provider. searchmanager searchmanager = (searchmanager) (searchmanager)getbasecontext().getapplicationcontext().getsystemservice(context.search_service); if (searchmanager != null) { list searchables = searchmanager.getsearchablesinglobalsearch();

        searchableinfo info = searchmanager.getsearchableinfo(getcomponentname());            (searchableinfo inf : searchables) {             log.e("nese",inf.getsuggestauthority());           } 

in searchable activity need save each search query in db:

@override protected void onnewintent(intent intent) {   setintent(intent);   handleintent(intent); }  private void handleintent(intent intent) {     if (intent.action_search.equals(intent.getaction())) {         string query = intent.getstringextra(searchmanager.query);         //use query search data somehow         searchrecentsuggestions suggestions =                 new searchrecentsuggestions(this,                         recentsuggestionsprovider.authority,                         recentsuggestionsprovider.mode);         suggestions.saverecentquery(query, null);     } } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -