Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to search contacts using serchable obtained from getSearchablesInGlobalSearch() in android

 
Mustafa Dasorwala
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can use the following code to search for applications if i use (inf.getSuggestAuthority().startsWith("applications"))but i am not able to search contacts using inf.getSuggestAuthority().startsWith("com.android.contacts"). Need help.
I am trying to create a general search tool for android.




res/menu/searchview_in_menu.xml

 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Searching contacts should be done via the ContactProvider. Here are some links on how:
Contacts Provider API Guide
Contacts Training
 
Mustafa Dasorwala
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:Searching contacts should be done via the ContactProvider. Here are some links on how:
Contacts Provider API Guide
Contacts Training


Thanks You for the reply Steve. What I am trying to create is a general search tool for android, can you gimme some pointers about what will be the best way to implement it.


Thanks & Regards
Mustafa I. Dasorwala
 
Mustafa Dasorwala
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:Searching contacts should be done via the ContactProvider. Here are some links on how:
Contacts Provider API Guide
Contacts Training


Also i would appreciate if you could tell me why the current code fails when I use "com.android.contacts" cause just like applications, contacts too are present in the searchables list.

Thanks.
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not, sure, can't say I have tried global searches - I just do contact specific searches. So I went to the SearchManager API and read it, and it says you will rarely ever need to interact with it, and that you should prefer using ACTION_SEARCH intents. This fires an intent that pings all apps and contexts that are searchable, so perhaps you should try to use that first.

Also, you still need permissions to get at contact data - did you request the proper permissions in your manifest?
 
Mustafa Dasorwala
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:Not, sure, can't say I have tried global searches - I just do contact specific searches. So I went to the SearchManager API and read it, and it says you will rarely ever need to interact with it, and that you should prefer using ACTION_SEARCH intents. This fires an intent that pings all apps and contexts that are searchable, so perhaps you should try to use that first.

Also, you still need permissions to get at contact data - did you request the proper permissions in your manifest?


Ya I did , both read and write permissions. I guess I'll use a different approach to solve the search problem.
Thanks Steve.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic