Puting contact number into field
<p>I have this code that has one button that let's me choose an entry from contacts, and passes that choesn contact to onActivityResult function. My question is how do I select data of that single contact when all that is passed is an Intent in data variable. That data variable, if converted to string shows something like "dat: content://contacts/people/4" so I see that selected contact is somehow passed, but what now? How to get that data?</p>

<p>And also all I found by googling was examples with deprecated class People, so I don't know how too use new classes.</p>

<p>Please help.</p>

<p>Thank you.</p>

<pre><code>public class HelloAndroid extends Activity {

    private static final int CONTACT_ACTIVITY = 100; 

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final Button contactButton = (Button) findViewById(R.id.pick_contact_button);
        contactButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Uri uri = Uri.parse("content://contacts/people");
                Intent contacts_intent = new Intent(Intent.ACTION_PICK, uri);
                startActivityForResult(contacts_intent, CONTACT_ACTIVITY); 
            }
        });     

    }

     public void onActivityResult(int requestCode, int resultCode, Intent data){
          super.onActivityResult(requestCode, resultCode, data);

          switch(requestCode){
              case(CONTACT_ACTIVITY): {
                  if(resultCode == Activity.RESULT_OK) {
                      alertText(data.toString());
                  }
                 break;
              }
          }
    }
}
</code></pre>
