*bump* ;-) 2009/10/18 Mariano Kamp <[email protected]>
> Hi, > > could you help me to understand search? > > Consider this simplified example: Let's say I have a contacts app with > two activities: ShowContactActivity and ShowContactsListActivity. > > I think that both activities should be search enabled when the user > types, but other than that ShowContactsListActivity doesn't play a role > anymore in the remaining post. I can set this up in the respective > onCreate() method (setDefaultKeyMode ( DEFAULT KEYS > SEARCH LOCAL )). > I want ShowContactActivity to be the target of a search, so that it > displays a single selected search result. I don't want to deal with the > search results presentation (for a list of hits) myself. The floating search > window is sufficient for that. > > So in the application tag I add this: > > <meta-data > android:name="android.app.default_searchable" > android:value=".ShowContactActivity" /> > > Which I think would enable all my activities for search and directs the > results from Global Search to ShowContactActivity, right? > > As part of the declaration of ShowContactActivity I add: > > <intent-filter> > <action > android:name="com.mysample.VIEW" /> > <category > android:name="android.intent.category.DEFAULT" /> > > </intent-filter> > > <intent-filter> > <action > android:name="android.intent.action.SEARCH" /> > <category > android:name="android.intent.category.DEFAULT" /> > </intent-filter> > > As well as the reference to the metadata: > > <meta-data > android:name="android.app.searchable" > android:resource="@xml/searchable" /> > > In the searchable I got this: > > <searchable > xmlns:android="http://schemas.android.com/apk/res/android" > android:label="search label, never seen used?!l" > android:hint="search hint, never seen used?!" > android:searchSuggestAuthority="contacts" > android:searchSuggestIntentAction="com.mysample.VIEW" > android:includeInGlobalSearch="true" > android:searchSettingsDescription="The subtitle of the search provider > in the global settings"> > </searchable> > > And also in the manifest I add this: > > <provider > android:name=".SearchProvider" > android:authorities="contacts" > android:syncable="false" /> > > The search provider returns a cursor with this columns: _id, > suggest_column_text_1, suggest_column_text_2, suggest_column_intent_data. > > So far this works wonderful for the local search. > > Now on to my questions. > > I am wondering why my ShowContactActivity is sometimes called with the > SEARCH action when invoked from global search. I think I am supposed to deal > with the query, but I really don't want to. I am happy with the floating > search hits box. > What happens is that I click on more results in the floating search box, > then my activity is called with SEARCH (and doesn't deal with it) and when I > hit BACK I get to the list of hits that I wanted to see in the first place. > > Why is the name of my search provider in the settings is the label of my > ShowContactActivity? > > Cheers, > Mariano > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

