我使用的是 2.1 平台,我可以使用下面的代码检索短信详细信息。但是只显示号码和短信正文,名称还没有出现,我该怎么做才能检索名称呢?
代码
public class SMSActivity extends Activity {
ListView lview;
String Body = "" ;
ArrayList<String> smslist=new ArrayList<String>();
ArrayAdapter<String> itemAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lview =(ListView)findViewById(R.id.lv);
itemAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,smslist);
lview.setAdapter(itemAdapter);
ContentResolver cr = getContentResolver();
Cursor c = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null);
while(c.moveToNext()){
Number = c.getString(c.getColumnIndexOrThrow("address"));
Body = c.getString(c.getColumnIndexOrThrow("body")).toString();
smslist.add( Number + ":" +"\n"+ Body);
}
itemAdapter.notifyDataSetChanged();
c.close();
}
}
如何解决这个问题呢 ?