As an android user, I would like to develop an app that installs a local contacts repo that is in parallel with the Google and Samsung contact providers/repos.
The reason is adding temporary contacts with a TTL. When looking for an apartment, I don't want all these random contacts. When selling something, I have just multitudes of contacts with no names just so I don't save these temps. When calling up moving companies, or any temporary agency ... I do not want these contacts forever on my phone.
How do I create a custom contacts repo such as in manage accounts?
I looked all over for something like this, and I found ContactProvider which felt like the right one, but after reading the docs, it doesn't quite fit. Tried AccountProvider but that is mostly about authorization from what I understand.
How can I add a contact provider such as Google Contacts or Samsung Contacts?
Related
In my android application I would like to display the mobile user's contacts (names, profile picture ) displaying first the contacts that have already installed and registrered that application (the matching is made by contact's email).
Trying to loop over each contact and match if their email is already registered (in an external SQLITE table) don't seems to be an efficient way.
I would like to directly add (somewhere in the address book ?) the extra data "isRegistered = true/false) and order my addreess book query by this value to scroll the address book.
Is it possible? How to implement this in detail ?
OPTION 1
I think the most efficient way would be what you thought about initially, with a slight improvement:
store the list of registered emails (for the user's contacts) in a local SQLite DB.
read the entire list of emails on application launch, and store them in a HashSet
When sorting the contacts, create a custom Comparator to first check if the contact is an app user or not, and only then fallback to name compare.
OPTION 2
If you still want to check the option of storing the custom value in the Contacts DB, and integrate it into your query, you need to create a SyncAdapter.
This is basically a service that is able to sync contacts to/from a server into your own RawContact, which is then aggregated into one-or-more existing RawContacts, like Google does for Google Contacts.
You can set it to be notified when a new contact is added, and have your SyncAdapter add the needed info to the contact so it'll show links to your app.
If you go to your phone settings > accounts, you can see Whatsapp and Google's SyncAdapters there, where you can turn them off/on.
To create a sync adapter, you can follow the official docs, or this great tutorial.
I have a requirement like, I can be able to find the people who are using a particular app from my contacts. It is much similar like Whatsapp contacts syncing.
Whatsapp contacts is so fast & very accurate. What is the logic for it?
I'm not sure of their exact logic, but a way that I have seen it done before is as follows...
Access the phone's contacts (duh)
Get the contact that you want to add as a "friend" in your app.
Cross reference that contact's phone number with the user information that you have stored in your application's database
If that phone number exists in your database of users, then you've got a match and you can process things however you'd like from there.
That's one way of doing it, but I don't know if that's exactly how WhatsApp does it. Hope this helps!
I'm building a small app for messaging (in some way a bit similar to 'WhatsApp' or 'Viber'). WhatsApp and Viber show you contacts that are from your contact list and have an account with them. so my question is how to sync?
For now, I have database which stores all users using the application and their phone number.
Do I need to run a query for each contact in my phone in order to find it in the database?
It looks a lot of queries for every sync request.
What is the efficient way in order to do this?
If you have both sets of data as database tables, then can't you just join on some attribute like 'Full Name' and the resulting table will be all people in your contacts list with the app installed?
You can display contacts in your app that are just pulled from the contact list on the phone. Using LoadManager you can get a contact list that is synced with the phone list.
Check out these links for more info
http://developer.android.com/training/contacts-provider/retrieve-names.html
https://developer.android.com/training/load-data-background/setup-loader.html
In my application that i write i have 2 or more contacts that i need to marge.
So i want to use the android feature "join" between those contacts to make this marge between than.
For example, I have contact "AAA" with an email account and a phone number, and I've noticed that some apps like whatsapp, Facebook and Skype are creating new contact entries for AAA, instead of merging the existing one.
How can i do it ?
I don't find any example on the web or anything how to do it.
There is an aggregate mode(RawContacts.AGGREGATION_MODE). Have a look at this Android not adding all contacts with duplicate fields
I need to add new contacts dynamically from my application.
I list all the phone accounts with the AccountManager getAccounts method but I get accounts like weather, stock, etc.
How can I get only contact accounts ?
There's actually no good way to do this by using the API, the method we found to be most accurate was to think backwards: which accounts are used for storing contacts?
It's a bit crude, but it gives pretty good results (cache the list and you don't need to do it every time).
// Pseudo-code
for contact in RawContacts
uniqueAccountTypes.put(contact.account)
for accountType in uniqueAccountTypes
uniqueAccountsWithContacts.putAll(accountManager.getAccountsByType(accountType))
I don't have access a copy of the contacts database right now, so the code above might be slightly off, but the concept should be clear. Let me know if I should clarify further.
Had a similar situation.
After a little search found this method of AccountManager:
getAccountsByTypeAndFeatures();
here if you set parameter features as "service_mail" , "service_talk" etc, you will get accounts supporting e-mail and chat, hence these accounts will support contacts also.
UPDATE
"service_ah" will give the account device is linked to.