I  try this code but here only we get Name are show
i want number also
public class test extends Activity
{
private EditText e;
Button bt;
private static final String DEBUG_TAG = "InviteActivity";
private static final int CONTACT_PICKER_RESULT = 1001;
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test);
    e=(EditText)findViewById(R.id.editText1);
    bt=(Button)findViewById(R.id.button1);
}

public void doLaunchContactPicker(View view)
{

    Intent contactPickerIntent = new
Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);
    startActivityForResult(contactPickerIntent,
CONTACT_PICKER_RESULT);

}

@Override
protected void onActivityResult(int requestCode,int resultCode,Intent
data)
{
    if(resultCode==RESULT_OK)
    {
        switch(requestCode)
        {
        case CONTACT_PICKER_RESULT:
            Cursor cursor=null;
            String phone="";
            try
            { Uri result=data.getData();
               String id=result.getLastPathSegment();
 
cursor=getContentResolver().query(Phone.CONTENT_URI,null,
Phone.CONTACT_ID +"=?",new String[] {id},null);
                int phoneIdx=cursor.getColumnIndex(Phone.NUMBER);
                if(cursor.moveToFirst())
                {
                phone=cursor.getString(phoneIdx);
                }
                if(phone.equals(""))
                {
                    Toast.makeText(getBaseContext(),"There is no phone
number for that contac", Toast.LENGTH_LONG).show();
                }
                else
                {
                e.setText(phone);
                }
            }
            catch(Exception e)
            {
                Toast.makeText(getBaseContext()," Exception There is
no phone number for that contact", Toast.LENGTH_SHORT).show();
            }

    }


}

}

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to