ContentResolver contentResolver = getContentResolver();
Cursor cursor = contentResolver.query( Uri.parse( "content://sms/inbox" ), null, null, null, null);
int indexBody = cursor.getColumnIndex( SmsReceiver.BODY );
int indexAddr = cursor.getColumnIndex( SmsReceiver.ADDRESS );
if ( indexBody < 0 || !cursor.moveToFirst() ) return;
smsList.clear();
do
{
String str = "Sender: " + cursor.getString( indexAddr ) + "\n" + cursor.getString( indexBody );//+"\n"+cursor.getInt( indexDate );
smsList.add( str );
}
while( cursor.moveToNext() );
ListView smsListView = (ListView) findViewById( R.id.SMSList );
smsListView.setAdapter( new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1, smsList) );
smsListView.setOnItemClickListener( this );
目前我使用地址栏显示短信发送者,因此会显示电话号码。我想用人名替换电话号码。我希望那个人包含它,但对于大多数短信来说它都是空的。然后,日期字段包含长值,当我想以DD.MM.YYYY格式显示它时