Keep different search histories for different activities?

I have two actions, and I would like them to support their own search queries. Is it possible? Each of them has its own provider of search suggestions, but I see the same search history that appears for both activities:

// manifest.xml
<activity
  android:name="ActivityA"
  ...
  <meta-data 
    android:name="android.app.searchable"
    android:resource="@xml/searchable_A" />
</activity>

<activity
  android:name="ActivityB"
  ...
  <meta-data 
    android:name="android.app.searchable"
    android:resource="@xml/searchable_B" />
</activity>


// searchable_A.xml
<searchable   
  android:searchSuggestAuthority="providerA" />

// searchable_B.xml
<searchable   
  android:searchSuggestAuthority="providerB" />

When saving search suggestions, I will definitely use the right provider for each type of activity.

// ActivityA.java
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(ActivityA.this,
    providerA.AUTHORITY, providerA.MODE);
suggestions.saveRecentQuery(...);

// ActivityB.java
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(ActivityB.this,
    providerB.AUTHORITY, providerB.MODE);
suggestions.saveRecentQuery(...);

Since the providers of search suggestions are different from each other, I expected each one to keep a different story. The use case here is that I have Activitydesigned for cars and Activitydesigned for products. I do not want the previous search conditions to be mixed together; they do not make sense in different contexts.

http://developer.android.com/guide/topics/search/adding-recent-query-suggestions.html

+5

All Articles