Search code examples
androidandroid-intentandroid-contactsphone-numbercontactscontract

How to display contact list programmatically in android?


I want to display the phone's contact log directly inside my application on a button click, in order to select a contact and its number. Can anybody help me with this?


Solution

  • I got the answer. :)

    String myData = "content://contacts/people/";
    Intent myActivity2 = newIntent(Intent.ACTION_VIEW, Uri.parse( myData) );
    startActivity(myActivity2); 
    

    or we can use

            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
            startActivityForResult(intent, 2);