Use Intent to pick contact People

Description

The following code shows how to Use Intent to pick contact People.

Example

Main Activity Java code


package com.java2s.myapplication4.app;
//from w w  w  . jav a2s .co m
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Contacts;
import android.view.Menu;

public class MainActivity extends Activity {

    private Intent contactIntent;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        contactIntent = new Intent();
        contactIntent.setAction(Intent.ACTION_PICK);
        contactIntent.setData(Contacts.People.CONTENT_URI);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add("Contacts").setIntent(contactIntent);
        return true;
    }

}




















Home »
  Android »
    Android Basics »




Hello Android
Resources
Activity
Calendar
Camera
Contact
Content Provider
Database
Hardware
Intent
Location
Media
Network
Notification
Preference
Sensor
Service
SMS