2013-07-21 1 views
0

나는 내 자신의 SMS 관리자를 쓰려고하는데, URI와 커서로 SMS와 MMS를 얻는 방법에 대한 많은 자습서를 찾았지만, 각각 시도 할 수 있습니다. 해결 안해. 당신이 좀 도와줬으면 좋겠다. 좋아요, 그래서 나는 "content : // mms-sms/conversations /"를 사용했는데 그것은 SMS와 MMS 모두에서 작동합니다. 당연히 아니지. 이 코드 : 내 표준 안드로이드 사서함을 열 때, 나는 18 대화를 계산하기 때문에, 거짓안드로이드에서 SMS 및 MMS를 얻으려고 시도 - HTC 문제

final String[ ] projection = new String[ ]{ "*" }; 
Uri uri = Uri.parse("content://mms-sms/conversations/"); 
Cursor query = getContentResolver().query(uri, projection, null, null, null); 

TextView text = (TextView)findViewById(R.id.textView1); 
text.setText(Integer.toString(query.getCount())); 

반환 13 .

두 번째 문제는, 또한 대화에서 "주소"를 얻으려고 노력 :

final String[] projection = new String[]{"*"}; 
Uri uri = Uri.parse("content://mms-sms/conversations/"); 
Cursor query = getContentResolver().query(uri, projection, null, null, null); 
while(query.moveToNext()) 
    System.out.println("recv " + query.getString(query.getColumnIndexOrThrow("address"))); 

때때로 주소가 때때로 수있는 이름으로, 때로는 null입니다. 왜? 이 문제를 어떻게 해결할 수 있습니까?

세 번째 사항은 많은 자습서에서 stackoverflow 너무 MMS에서 주소를 얻는 방법은 매우 간단합니다. MMS에서 cursor.getString (cursor.getColumnIndexOrThrow ("address"))을 가져 와서 완료하십시오. 여기 HTC에 없습니다. 나는이 시도 :

Cursor cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null); 
if(cursor.moveToFirst()) 
{ 
    for(int i = 0; i < cursor.getColumnCount(); i++) 
     System.out.println("SMS " + cursor.getColumnName(i)); 
} 

for(int i = 0; i < 3; i++) 
     System.out.println("***************************************************************"); 

Cursor cursor2 = getContentResolver().query(Uri.parse("content://mms/inbox"), null, null, null, null); 
if(cursor2.moveToFirst()) 
{ 
    for(int i = 0; i < cursor2.getColumnCount(); i++) 
     System.out.println("MMS " + cursor2.getColumnName(i)); 
} 

을 그리고 그것은 나를 반환

07-21 02:12:40.631: I/System.out(25221): SMS _id 
07-21 02:12:40.631: I/System.out(25221): SMS thread_id 
07-21 02:12:40.631: I/System.out(25221): SMS toa 
07-21 02:12:40.631: I/System.out(25221): SMS address 
07-21 02:12:40.631: I/System.out(25221): SMS person 
07-21 02:12:40.631: I/System.out(25221): SMS date 
07-21 02:12:40.631: I/System.out(25221): SMS protocol 
07-21 02:12:40.631: I/System.out(25221): SMS read 
07-21 02:12:40.631: I/System.out(25221): SMS status 
07-21 02:12:40.631: I/System.out(25221): SMS type 
07-21 02:12:40.631: I/System.out(25221): SMS reply_path_present 
07-21 02:12:40.631: I/System.out(25221): SMS subject 
07-21 02:12:40.631: I/System.out(25221): SMS body 
07-21 02:12:40.631: I/System.out(25221): SMS sc_toa 
07-21 02:12:40.631: I/System.out(25221): SMS report_date 
07-21 02:12:40.631: I/System.out(25221): SMS service_center 
07-21 02:12:40.631: I/System.out(25221): SMS locked 
07-21 02:12:40.631: I/System.out(25221): SMS index_on_sim 
07-21 02:12:40.631: I/System.out(25221): SMS callback_number 
07-21 02:12:40.631: I/System.out(25221): SMS priority 
07-21 02:12:40.631: I/System.out(25221): SMS htc_category 
07-21 02:12:40.631: I/System.out(25221): SMS cs_timestamp 
07-21 02:12:40.631: I/System.out(25221): SMS cs_id 
07-21 02:12:40.631: I/System.out(25221): SMS cs_synced 
07-21 02:12:40.631: I/System.out(25221): SMS error_code 
07-21 02:12:40.631: I/System.out(25221): SMS seen 
07-21 02:12:40.641: I/System.out(25221): SMS is_cdma_format 
07-21 02:12:40.641: I/System.out(25221): SMS is_evdo 
07-21 02:12:40.641: I/System.out(25221): SMS c_type 
07-21 02:12:40.641: I/System.out(25221): SMS exp 
07-21 02:12:40.641: I/System.out(25221): SMS gid 
07-21 02:12:40.641: I/System.out(25221): SMS extra 
07-21 02:12:40.641: I/System.out(25221): SMS date2 
07-21 02:12:40.641: I/System.out(25221): 
*************************************************************** 
07-21 02:12:40.641: I/System.out(25221): 
*************************************************************** 
07-21 02:12:40.641: I/System.out(25221): 
*************************************************************** 
07-21 02:12:40.691: I/System.out(25221): MMS _id 
07-21 02:12:40.691: I/System.out(25221): MMS thread_id 
07-21 02:12:40.691: I/System.out(25221): MMS date 
07-21 02:12:40.691: I/System.out(25221): MMS msg_box 
07-21 02:12:40.691: I/System.out(25221): MMS read 
07-21 02:12:40.691: I/System.out(25221): MMS m_id 
07-21 02:12:40.691: I/System.out(25221): MMS sub 
07-21 02:12:40.691: I/System.out(25221): MMS sub_cs 
07-21 02:12:40.691: I/System.out(25221): MMS ct_t 
07-21 02:12:40.691: I/System.out(25221): MMS ct_l 
07-21 02:12:40.691: I/System.out(25221): MMS exp 
07-21 02:12:40.691: I/System.out(25221): MMS m_cls 
07-21 02:12:40.691: I/System.out(25221): MMS m_type 
07-21 02:12:40.691: I/System.out(25221): MMS v 
07-21 02:12:40.691: I/System.out(25221): MMS m_size 
07-21 02:12:40.691: I/System.out(25221): MMS pri 
07-21 02:12:40.691: I/System.out(25221): MMS rr 
07-21 02:12:40.691: I/System.out(25221): MMS rpt_a 
07-21 02:12:40.691: I/System.out(25221): MMS resp_st 
07-21 02:12:40.691: I/System.out(25221): MMS st 
07-21 02:12:40.691: I/System.out(25221): MMS tr_id 
07-21 02:12:40.691: I/System.out(25221): MMS retr_st 
07-21 02:12:40.691: I/System.out(25221): MMS retr_txt 
07-21 02:12:40.691: I/System.out(25221): MMS retr_txt_cs 
07-21 02:12:40.691: I/System.out(25221): MMS read_status 
07-21 02:12:40.691: I/System.out(25221): MMS ct_cls 
07-21 02:12:40.691: I/System.out(25221): MMS resp_txt 
07-21 02:12:40.691: I/System.out(25221): MMS d_tm 
07-21 02:12:40.691: I/System.out(25221): MMS d_rpt 
07-21 02:12:40.691: I/System.out(25221): MMS locked 
07-21 02:12:40.691: I/System.out(25221): MMS htc_category 
07-21 02:12:40.691: I/System.out(25221): MMS cs_timestamp 
07-21 02:12:40.691: I/System.out(25221): MMS cs_id 
07-21 02:12:40.691: I/System.out(25221): MMS cs_synced 
07-21 02:12:40.691: I/System.out(25221): MMS seen 
07-21 02:12:40.691: I/System.out(25221): MMS extra 
07-21 02:12:40.691: I/System.out(25221): MMS phone_type 
07-21 02:12:40.691: I/System.out(25221): MMS date2 

그래서 그것이 내가 MMS에서 NO 필드 "주소"가 없음을 의미합니다. 그러면 주소를 어떻게 알 수 있습니까? 나는 실을 얻을 수 있지만 대화의 반은 보이지 않습니다. 자신의 SMS/MMS 관리자 코드를 작성하는 것은 불가능한 것처럼 보입니다. HTC에는 많은 버그가 있습니다.

휴대 전화에서 정상적으로 작동하는 'GO SMS Pro'라는 앱이 Google Play에 있습니다. 그래서 을 올바르게 코딩하는 방법이 있습니다.. 내가 뭘 잘못 했니? 문제를 해결하고 SMS 및 MMS를 올바르게받을 수 있습니까?

답변

0

에서 변경 "내용 : // MMS-SMS는/대화 /"에서 "내용 : // MMS-SMS/대화"

0

시도

Uri uri = Uri.parse("content://mms-sms/conversations?simple=true"); 
관련 문제