2011-12-01 74 views
0

請告訴我如何獲取郵件發件人的姓名。我試着跟隨。所有領域工作正常,但名稱始終爲0.請給我解決方案。獲取郵件發件人的姓名

String SORT_ORDER = "date DESC"; 
    int count = 0; 
    String[] str= new String[] { "_id", "thread_id", "address", "person", "date", "body" }; 

    Cursor cursor = getContentResolver().query(
      Uri.parse("content://sms"), 
      str, 
      null, 
      null, 
      SORT_ORDER); 
    Log.e("!!!!!!!!", ""+cursor.getCount()); 

    while (cursor.moveToNext()) { 
     try { 
      // count = cursor.getCount(); 

      long messageId = cursor.getLong(0); 
      long threadId = cursor.getLong(1); 
      String address = cursor.getString(2); 
      long contactId = cursor.getLong(3); 
      String contactId_string = String.valueOf(contactId); 
      long timestamp = cursor.getLong(4); 

      String body = cursor.getString(5); 
      Log.e("!!!!!!!!", "number"+address); 
      Log.e("!!!!!!!!", "name"+contactId_string); 

回答

0

我想你會得到你在PhoneLookup

Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); 
resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME} .....) 
+0

搜索我不能夠使用這些codes.Thanx – william

+0

得到消息發送者的名字郵件發件人的數量,其Android版本你正在使用來測試它? –

相關問題