Hi,
I tried so much tutorials, and read a lot here at SO, but i cant solve my problem:
When a button is clicked, the user can choose the mobile number of a contact. Actual I can get the name of the selected contact, but i can't find a way, to get/chose the mobile number..
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/** Layouting */
this.mGetMobileNumberButton = (Button)findViewById(R.id.getMobileNumberButton);
this.mNameTextView = (TextView)findViewById(R.id.nameTextView);
this.mMobileNumberTextView = (TextView)findViewById(R.id.mobileNumberTextView);
/** onClick getContactInfos*/
this.mGetMobileNumberButton.setOnClickListener(new OnClickListener() {
public void onClick(View v){
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, 1);
}
});
}
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
super.onActivityResult(reqCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
Uri contactData = data.getData();
Cursor c = managedQuery(contactData, null, null, null, null);
if (c.moveToFirst()) {
String name = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
mNameTextView.setText(name);
}
}
}
Hope anyone can help :)