how to display device address book ordered by custom external data - android

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.

Related

How to show list of phone contacts that are using same app as me?

I am creating a custom app for planning events. It has a SMS based authentication. Now I want to create a list of people who are already using the app (like the list of contacts in WhatsApp). Is there any way to do this in Android?
If I get you right, you can do this in 3 steps:
When a user registers on your app, save the user in say "ActiveNumbers" database on your server.
Ask contacts permission from users.
Do a join of the contacts and ActiveNumbers table, list the valid contacts in the people section of your app.
Does it solve your problem?

Retrieving list of users in my Android App through Parse that match Phone's contacts

I am developing an Android chat messaging app using Parse where I am saving user's phone number, username, and password during the sign-up process that I have completed successfully.
Now, I want to fetch the list of users already saved under the Phone Contact list matching their phone numbers and display the users in a list view. I am stuck of writing the Parse query and showing the fetched users in a list view.
What you can do is the following:
Get all your contacts phone numbers into a list
In ParseQuery use the following method (from parse docs website)
Please make sure that your contacts list is not too large in order to avoid performance issues. If it's too large you can split it and execute 2 calls and then merge them on the client side.
if you need more info please let me know.

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