0
私は、電話機から連絡先を読み取るアプリケーションを作成しましたが、3.1のプラットフォームバージョンで正常に動作しますが、2.3.3プラットフォームで実行するとNullPointerExceptionがスローされます。このエラーの理由。androidの読書連絡先の2つのバージョン間の競合
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();
}
ありがとう。
私はすでにthat.itを3.1で使用していますが、2.3.3では使用していません。 – sampathpremarathna