我正在编写一款依赖于在手机上提取用户姓名和个人资料照片的应用。我知道我可以做到以下几点:
// Retrieve owner's name
String[] fields = {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.PHOTO_URI};
Cursor curs = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI, fields, null, null, null);
if (curs != null) {
curs.moveToFirst();
if (curs.getCount() > 0){
profile.put(NAME, curs.getString(0));
ContactPickerActivity.name = curs.getString(0);
profile.put(PIC, curs.getString(1));
ContactPickerActivity.imageUri = curs.getString(1);
}
curs.close();
}
toDisplay += "Owner of phone: " + profile.get(NAME) + "\n";
这个问题是它只适用于API 14及更高版本。是否有任何类似的方法适用于早期版本?