4

I want to get contact number from contact list. In Android application on button i want get number from contact list of phone.

Means it click on Select button, & open contact list. it select number, & display in textview.

Please give me a solution.

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);

@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
  super.onActivityResult(reqCode, resultCode, data);

  switch (reqCode) {
    case (PICK_CONTACT) :
      if (resultCode == Activity.RESULT_OK) {
        Uri contactData = data.getData();
        Cursor c =  getContentResolver().query(contactData, null, null, null, null);
        if (c.moveToFirst()) {
          String name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
          // TODO Whatever you want to do with the selected contact name.
        }
      }
      break;
  }
}
Christoph
  • 47,569
  • 8
  • 87
  • 187
Nitin Karale
  • 789
  • 3
  • 12
  • 34
  • If you google it, there is ready made example is available. Please dont ask for code directly. Show some effort. – Vigbyor Nov 18 '13 at 09:38
  • @Vigbyor i already tried. But when it select number from contact list, it got error "Unfortunately stop". – Nitin Karale Nov 18 '13 at 09:43
  • Good, then you should upload your code, this way it helps us to catch the error you are facing :) – Vigbyor Nov 18 '13 at 09:45
  • Your question is much more abstract. Please elaborate your question programatically. Show what have you tried so far. Post Logcat details. – Chintan Soni Nov 18 '13 at 09:45
  • @shree202 Please see the following link http://stackoverflow.com/questions/866769/how-to-call-android-contacts-list – Nitin Karale Nov 18 '13 at 09:47
  • The answer got from bellow the question http://stackoverflow.com/questions/4993063/how-to-call-android-contacts-list-and-select-one-phone-number-from-its-details-s – Nitin Karale Nov 20 '13 at 08:16
  • actual answer is available on http://stackoverflow.com/questions/866769/how-to-call-android-contacts-list – The EasyLearn Academy Jan 31 '17 at 00:30

1 Answers1

2

I got this answer from the following link

http://tutorials-android.blogspot.in/2011/11/how-to-call-android-contacts-list.html

Nitin Karale
  • 789
  • 3
  • 12
  • 34