我想檢索與傳入消息號碼關聯的聯繫人姓名。 我想出了以下代碼。使用電話號碼搜索聯繫人
Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(msgSender));
Cursor c = getContentResolver().query(lookupUri, new String[]{Contacts.DISPLAY_NAME},null,null,null);
try {
c.moveToFirst();
displayName = c.getString(0);
} catch (Exception e) {
// TODO: handle exception
}finally{
c.close();
}
問題是,它在仿真器上工作,但沒有在我的移動設備上工作。我試過重新啓動我的手機。但仍然沒有工作。我搜索了與此類似的代碼,但並未在實際的手機上工作。
你的讀手機是什麼版本? – Herry 2012-04-14 10:29:53
版本是2.3.5。 – 2012-04-14 10:30:59