public class PhonebookActivity extends ListActivity {
String tag = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Cursor cursor = getURI();
int end = cursor.getCount();
Log.d(tag, "end = "+end);
String [] name = new String[end];
int count = 0;
if(cursor.moveToFirst())
{
int idIndex = cursor.getColumnIndex("_id");
do
{
int id = cursor.getInt(idIndex);
name[count] = cursor.getString(1);
Log.d(tag, "id=" + id +", name["+count+"]=" + name[count]);
count++;
} while(cursor.moveToNext() || count > end);
}
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, name));
final ListView listView = getListView();
listView.setItemsCanFocus(false);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
private Cursor getURI()
{
Uri people = Contacts.CONTENT_URI;
String[] projection = new String[] { Contacts._ID, Contacts.DISPLAY_NAME, Contacts.HAS_PHONE_NUMBER };
String[] selectionArgs = null;
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
return managedQuery(people, projection, null, selectionArgs, sortOrder);
// TODO Auto-generated method stub
}
}
주소록을 불러와서 다중체크가 가능한 리스트뷰를 구현 했는데요..
핸드폰에서 작동시켜보니까 핸드폰 연락처에 있는 사람 뿐만 아니라 트위터 팔로윙한 사람 아이디까지 나타나네요 ㅜㅜ
연락처에 있는 사람들 목록만 가져올 수 없을까요...?




query 날릴때 mimetype을 android 것만 걸르도록 해 보세요