Currently i am getting my contacts like this.
public class InviteFriends {
Activity activity ;
public void invite(Activity _activity) {
activity = _activity;
String columns[] = new String[] {People.NAME, People.NUMBER};
Uri mContacts = People.CONTENT_URI;
Cursor c = _activity.managedQuery(mContacts, columns, //
Which columns to return
null, // WHERE clause; which rows to return(all rows)
null, // WHERE clause selection arguments (none)
Contacts.People.DEFAULT_SORT_ORDER // Order-by clause
(ascending by name)
);
String [] contacts = new String[c.getCount()];
boolean [] contactValue = new boolean[c.getCount()];
if (c.moveToFirst()) {
String name = null;
String phoneNo = null;
int i = 0;
do {
// Get the field values
name = c.getString(c.getColumnIndex(People.NAME));
phoneNo = c.getString(c.getColumnIndex(People.NUMBER));
Log.i("", " Name = " + name+"
Number =
"+phoneNo);
contacts[i] = name+"\n"+phoneNo;
contactValue[i] = false;
Log.i(" I = "+i, ""+contacts[i]);
if(i<c.getCount()){
i++;
}
} while (c.moveToNext());
}
new AlertDialog.Builder(_activity)
.setIcon(R.drawable.invite_friends_icon)
.setTitle("Invite Friends")
.setMultiChoiceItems(contacts,
contactValue,
new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog,
int whichButton,
boolean isChecked) {
Log.i("Checked ", ""+isChecked);
}
})
.setPositiveButton("Invite", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int
whichButton) {
String inviteFriendNumList =
VOPUtility.extractDetailsInInternationalFormat(numbers);
Log.i("Invite Friends Numbers ",
""+inviteFriendNumList);
}
})
.setNegativeButton("Cancel", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int
whichButton) {
}
})
.show();
}
}
currently i m getting my contacts using this code snipt and showing
all my contact names with phone numbers
on a Multi choice alert dialog successfully with all unchecked check
boxes.
My first Question is this:
For example i have a contact name Jonas and i have saved three phone
numbers against this contact like first is Mobile number, second is
Home number and third is Work number .How i can get these there
numbers in my list which is showing on dialog ?
and My second question:
if user checked some contacts on alert dialog how i can get checked
contact numbers ? and how i can store them in a string array seprated
by comma.
any one can help me regarding this.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---