• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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

 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • 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: 4179
22
IntelliJ IDE Python Java
  • 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.
 
Let me tell you a story about a man named Jed. He made this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic