I need your help. I'm developing an app which needs user to register account like Viber. What I want to include is to check if one of my contacts has already an account in Viber as well. Do you have ideas how to do that? I've been googling and haven't found anything relevant.
Asked
Active
Viewed 2,044 times
2
-
In such situation after registration in app you can send your contacts to server, and server will return only those contacts to you which already registered in app. – Rahul Sharma Mar 16 '15 at 05:38
-
how can I send my contacts to server? – Mar 16 '15 at 05:41
-
Exactly even i have also worked on some app which API responses gave me whether user is registered or not But that was for my app only. check if there any Api exist for viber or not – Hardy Mar 16 '15 at 05:44
-
@Hardipatel hmm actually I only need to check my contact's email addresses. – Mar 16 '15 at 05:51
-
Using Email content resolver you can get all the email addreses related your devices and then check by sending to the server – Hardy Mar 16 '15 at 05:57
2 Answers
0
If you are going to develop a similar app like viber.I think you can get the complete contact by susing contactsprovider and display it in a listview on clicking on a row in this listview you can pass it to your server in the server set phone number as unique field,so that you can check for match.
Karthika PB
- 1,373
- 9
- 16
-
-
then you can go with setting emailaddress as unique fild but for a calling application I think phone number should be unique...and sending the required contact to check only is more less load if it's ok for your requirement. – Karthika PB Mar 16 '15 at 05:56
0
You can get all contacts from using code below and then send to your server:
ArrayList<String> listAllContactName = new ArrayList<String>();
ArrayList<String> listAllContacts = new ArrayList<String>();
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
if (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
//here you can get all contact names
listAllContactName.add(name);
System.out.println("name : " + name + ", ID : " + id);
// get the <span class="IL_AD" id="IL_AD4">phone number</span>
Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
new String[]{id}, null);
while (pCur.moveToNext()) {
String phone = pCur.getString(
pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
System.out.println("phone" + phone);
listAllContacts.add(phone);
}
pCur.close();
Rahul Sharma
- 5,949
- 5
- 36
- 46
-
Then I will get the contact's email address to check against db from server, if they're registered or not. – Mar 16 '15 at 05:51
-
i think when you send contacts list to server, then server side automatically check email id related to contacts. and will check whether user is registered or not – Rahul Sharma Mar 16 '15 at 05:53
-
-
Checking the phone number stored on the phone is not very reliable. It doesn't always retrieve the phone number. Also going to the server to check if the user is registered is not very expandable. What if you have 1 mil users? They will wait for minutes just for one check. I suggest you look into secure storage – Catalina Mar 16 '15 at 07:00