0
전화에서 연락처를 읽는 응용 프로그램을 만들었고 플랫폼 버전 3.1에서 제대로 작동하지만 2.3.3 플랫폼에서 실행할 때 NullPointerException이 발생합니다. 이 오류의 원인.안드로이드에서 연락처를 읽는 두 버전 사이에 충돌이 발생했습니다.
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null,null, null, null);
while (cur.moveToNext()) {
String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
Cursor phones = cr.query(Phone.CONTENT_URI, null,
Phone.CONTACT_ID + " = " + id, null, null);
while (phones.moveToNext()) {
String number = phones.getString(phones.getColumnIndex(Phone.NUMBER));
int type = phones.getInt(phones.getColumnIndex(Phone.TYPE));
System.out.println("Numeber= "+number);
switch (type) {
case Phone.TYPE_HOME:
home=number;
break;
case Phone.TYPE_MOBILE:
mobile=number;
break;
case Phone.TYPE_WORK:
work=number;
break;
case Phone.TYPE_OTHER:
other=number;
break;
}
}
phones.close();
}
감사합니다.
이미 3.1에서 작동하지만 2.3.3에서는 작동하지 않습니다. – sampathpremarathna