Reading contacts from phone book in Android - android

I 'm trying to read and display contacts from phone book in android. My Device is synced up with gmail and funambol which togehter have more than 600 records. Now by default my application reads gmail contacts. On selecting any contact from the displayed list, it throws an exception as the list is displaying a gmail contact which just has email and no phone no.
I need phone no to use in my application.
thanks

Take a look at this answer here. It provides all the detail you need to get the contacts right.
The reason for the crash might be because you are trying to read the phone number when there is none, causing a NullPointerException. Maybe check if it's null before you try and use it, and if it is null then ask the user to pick again.
If this isn't right, feel free to provide more detail like code and logcat logs.

Related

whatsapp hyperlink - combine whatsapp://send? with intent://send/

It's possible to have a button in my web page, for sending pre-filled messages to specific number?
i'm trying with
intent://send/+391234567890#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end;whatsapp://send?text=
nothing result.
have a solution? Thanks
Firstly, write the country code without +
Message me in WhatsApp
Sadly this does not work unless the number is already in your contacts list! Making it useless.
Here's what happens for me: I get a modal dialog saying the user is not on WhatsApp and I can either Invite or SMS. This is a mistake - they're DEFINITELY on WhatsApp, but not in my contacts because I've deleted them for testing.
Workaround idea
Offer vCard to save to Contacts
Since the phone number has to be in the Contacts list first, let's get it there. Track the site visitor to see if it's the first time she tapped on Contact me on WhatsApp (a cookie?). If it's the first time she tapped, make the link download your vCard
href="johnsmith.vcf"
The user now has to open the downloaded vCard with the People app, and add you to her Contacts.
Android intents URI FTW
When she returns, assuming she added you, make the button work with the intent:// URI scheme.
href="intent://send/391234567890#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end"
She taps on it and is magically transported to a WhatsApp chat with you.
Keep track of which href to present
Hopefully you can use the cookie you set to track her so you don't have the button offer the vCard AGAIN. There's no other way to know if your number is in her Contacts list unless you ask. But then it's not a button anymore, it's a form.
Same goes for Telegram. Security implications are probably the ones keeping Instant Messaging not so instant.

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!

Get full google contacts list using OAuth

I'm trying to receive the user contact list from gmail using this (http://androidwarzone.blogspot.com.br/2011/07/android-oauth-full-example-with-source.html) tutorial. Everything worked just great, but I'm just receiving 24 contacts, nothing more, nothing less. If i delete an contact that is receiving and try to get the list again, ir brings me another contact placing the deleted spot.
How do I get the full list? There is a better way instead of this tutorial?
All contacts, including gmail, can be queried directly from the contacts content provider on the device.
http://developer.android.com/guide/topics/providers/contacts-provider.html#Access
In the tutorial what u have mentioned, in C.java file, for GET_CONTACTS_FROM_GOOGLE_REQUEST use this url https://www.google.com/m8/feeds/contacts/default/full?max-results=1000&alt=json
Here max-results=1000 means maximum 1000 results to retrieve per request

android check if a contact installed an app android (like whatsapp)

I want to let my app scan the users contactlist , and display the name of the contacts who also installed the app.
I have no idea where to begin with this . so if someone could help me getting started , that would be apreciated.
grtz
You will need to research ContentResolver because you will have to query the database containing the contacts. To do these queries, you will need the URI and column/header names for contacts db which can be found in the Contacts class.
You will also need users to register that they have your app on your own servers and the registration will need a piece of information about the user that other users would have in their contacts (the users phone number, email address, etc).
You will then need to query a few users at a time from the users contacts for this piece of information (using the ContentResolver and Contacts class), pass it to your server (as text) where it will check if they are registered, then send a message back to initial user (and possibly the match) that you found a match.
That's where you should start, and end :)
Note, you will need these permissions in the Manifest file:
android.permission.INTERNET
android.permission.READ_CONTACTS
First of all, welcome to StackOverflow. StackOverflow is for programming questions. As is such, a post asking for help should always provide a description of what you have already tried. If you haven't tried anything yet, I highly encourage you to try something, and post when you encounter a problem.
As your question stands now, we don't know what the problem is. Are you having problems scanning a contact list? Or are you having problems trying to figure out if another user has installed the app?
That being said, you will have to maintain a database for your app containing a list of people who have installed your app. When your app is launched on one device, do whatever you need to do to register the user in your database. Due to the nature of a "contact," one person's phone may only have their phone number, email address, or even just a name. This is of course something you will have to deal with in your implementation.

Filter out Facebook Contacts from the Contact Picker

I have a contact picker in my application that keeps crashing when a facebook contact is selected. I won't have the code I'm using to open the picker in front of me, but I believe I'm accessing the contacts through a call similar to this:
new Intent(Intent.ACTION_PICK, People.CONTENT_URI)
Does anyone have experience with this?
i wish i had an answer for you but i posted 2 similar questions without any good answers. seems like a totally reasonable question and easy to do in most other dev environments (im actually a c# developer) but android has got me stuck on this. i think i may just have to write my "own contact picker" so that i can test for the fact that the contact has a number before adding them to the picker list programmatically.
anyways, my questions are here:
How do get the android sdk contact picker to give me just phone results and not all my twitter followers
how do i get startActivityForResult() to bring up just a list of telephone contacts (like when i click on the "People" icon) using the android sdk?
in my app i am testing that the phone gets returned from the picked contact before trying to send it a message (so mine doesnt crash), but i dont want the user to have to see a "that contact doesnt have a number" message if they dont have to.
i found this too:
http://mobile.dzone.com/news/contacts-api-20-and-above
while it DOESNT show you how to filter the contact list, it does show how to programmatically create a list that has only contacts with numbers. write back on my questions if you find anything that could be useful, thanks!

Categories

Resources