Я пытаюсь написать свой собственный диспетчер SMS, и я нашел много учебников, как получить SMS и MMS с URI и курсором, но каждый раз, когда у меня возникают проблемы, я могу Решить. Надеюсь, ты мне немного поможешь. Хорошо, поэтому я использовал «content: // mms-sms/conversations /», который должен работать как для SMS, так и для MMS. Конечно нет. Этот код:Попытка получить SMS и MMS на Android - Проблемы с 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 который является ложным, потому что, когда я открыл свой почтовый ящик стандартный андроида, я насчитал 18 разговоров.
Вторая вещь, также пытался получить «адрес» из разговоров:
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")));
Иногда адрес является числом, иногда это имя, а иногда является недействительным. Зачем? Как я могу это исправить?
Третье, во многих учебниках, в stackoverflow тоже есть очень простое решение, как получить адреса из MMS. Просто запустите cursor.getString (cursor.getColumnIndexOrThrow («адрес»)) из MMS и сделайте. Не здесь, на 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. Итак, как я могу получить адрес? Я могу получить только поток, но половина разговора невидима. Похоже, что невозможно создать собственный диспетчер SMS/MMS, на HTC так много ошибок.
В Google Play есть приложение «GO SMS Pro», которое отлично работает на моем телефоне. Так значит, есть способ правильно его закодировать. Что я делаю неправильно? Как я могу исправить это и правильно получить SMS и MMS?