Open contacts activity from your app

Navigation between applications in Android it’s smooth. You can go back and forward through activities without noticing which are built in and which are not.

The example below will show you a way of selecting a contact from your application, but first starting the built in functionality and then passing into your app the selected item, in our case only the display name.


Button click handler that will open Contact activity

private OnClickListener onClickPickContact = new OnClickListener() {

public void onClick(View arg0) {
Intent intent = new Intent(Intent.ACTION_PICK,
startActivityForResult(intent, 0);


How to grab that picked contact and show it in a toast over the screen

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

if (resultCode == Activity.RESULT_OK && requestCode == 0) {
Cursor cursor = getContentResolver().query(data.getData(),
new String[] { ContactsContract.Contacts.DISPLAY_NAME },
null, null, null);

if (cursor.moveToFirst()) {
int columnIndex = cursor
String name = cursor.getString(columnIndex);
Toast.makeText(getApplicationContext(), name, Toast.LENGTH_LONG)