message = contentResolver.query(uri, null,null, null,SORT_ORDER);
if(message != null){
while (message.moveToNext()) {
String id = message.getString(message.getColumnIndex("_id"));
String thid = message.getString(message.getColumnIndex("thread_id"));
String phoneNumber = message.getString(message.getColumnIndex("address"));
String person = message.getString(message.getColumnIndex("person"));
//String present = message.getString(message.getColumnIndex("reply_path_present"));
//Log.v("sms "+thid,id);
//Log.v("sms "+present,present);
if(phoneNumber !=null){
//if(phoneNumber.contains("-"))
phoneNumber=phoneNumber.replaceAll("[-() ]", "");
}
else
{
Cursor c =contentResolver.query(Uri.parse("content://mms-sms/conversations?simple=true"), null, "_id = " + thid, null, null);
//getContentResolver().query(Uri.parse("content://mms-sms/canonical-addresses"), null, "_id = " + recipientId, null, null);
if(c.moveToNext())
{
phoneNumber = c.getString(3);
if(phoneNumber !=null){
//if(phoneNumber.contains("-"))
Log.v(" id=>" +id+ " thid=>"+thid +" first = > " , c.getString(3));
}
}
c.close();
c =contentResolver.query(Uri.parse("content://mms-sms/canonical-addresses"), null, "_id = " + phoneNumber, null, null);
if(c.moveToNext())
{
Log.v(thid +" second = > " , c.getString(1));
phoneNumber = c.getString(1);
phoneNumber=phoneNumber.replaceAll("[-() ]", "");
}
c.close();
@ Vikki..thanks很多 – sarath
這SOOO幫助很大 – toobsco42
哎@Vikki,如果你想從URI「的內容得到的thread_id什麼:// MMS短信/通話?簡單=真」。你會怎麼做? – toobsco42