How to have a custom contacts list in Android - android

This is my first application in Android. I am trying to maintain a list of contacts (a subset of the phone contacts) in my own application. I was to an extent read the contacts from Android and try to manipulate with it. But the challenge I face is,
Storing the contacts (persisting) in the application preferably through Preferences. (ListPreference not usable for this).
I only need name, phone number and email from every contact and display it in a list view.
The equivalent iPhone version looks like this. But how to close achieve this in Android
Any tips on achieving the above is much appreciated.

If it is a subset of the phone contacts why don't you store in a SQLite table just the lookup-URI of the contacts you want to have in your subset? You can store both the contact lookup-URI and ID if you are worried about the performances of lookup-uri.

Related

how to display device address book ordered by custom external data

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.

What is mechanism of Whatsapp application's Contacts syncing?

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!

Which contacts have my application installed?

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

Custom Contacts List in Android

I am looking to build a local Contacts list in Android. The user selects, say 3 contacts, from the address book and the code needs to save this list locally. The list should include Contact name, mobile number and email address. The user should also be able to edit this list. I am new to Android and struggling to get a solution for this.
The app I am building needs a user to create a local contacts list. I need to be able to extract the full contacts list from the Address Book and then the user gets to choose a limited number of contacts which get saved for later retrieval/modifications.
try Retrieving a List of Contacts in Android Developer.
This link may helps you to retrive the contact list.
Replace book objects with contact objects in the following tutorial and it might be useful...
http://stirfriedcode.blogspot.jp/2013/11/getting-specific-data-from-sqlite.html
I tried a new workaround and adapter-free solution . It's worth to have a look at :
https://github.com/draxdave/ConstraintAccordion

Possibility of a custom Contacts field with a set list of values and Contacts lookup performance

I'm pretty sure it's not viable to do what I'd like to based on some initial research, but I figured it couldn't hurt to ask the community of experts here in case someone knows a way.
I'd like to create a custom field for contacts that the user is able to edit from the main Contacts app; however, the user should only be allowed to select from a list of four specific values. A short list of string values would be ideal, but an int with a min/max range would suffice.
I'm interested in knowing if it's possible either way, but also wondering if it make sense to go this route performance wise. More specifically, would it be better to look up a contact (based on a phone number) each time a call or SMS message is received or better to store my own set of data (consisting of name, numbers, and the custom field) and just syncing contact info in a thread every so often? Or syncing contacts the first time the app is run and then registering for changes using ContentObserver?
Here is a similar question with an answer that explains how to add a custom field to a contact.
Thanks in advance.
I don't see the purpose to have your own set of data against contacts stored in your separate database, as you obviously will run into sync issues. You can use the mimetype and store whatever you want against the contact, in the manner you linked.
Whenever you want to looup contacts you can do that by using your custom mimetype. You get the contact id (from ContactsContract.Data.CONTENT_URI), and then you run another query to get the contact details (from ContactsContract.Contacts.CONTENT_URI). Please note these are different tables.
I'd like to create a custom field for contacts that the user is able to edit from the main Contacts app
I don't see that possible, editable from the main app, when you use your custom mimetypes, and you don't have much options here. The main contact app will display only the fields that are in SDK. You can store details against contacts but they won't show up in the inbuilt edit contact screen.

Categories

Resources