我在Android中有一个应用程序,旨在获取收到的倒数第二条消息,但我找不到方法。我有以下代码:
ArrayList<String> smsList = new ArrayList<String>();
ContentResolver contentResolver = getContentResolver();
Cursor cursor = contentResolver.query( Uri.parse( "content://sms/inbox" ), null, null, null, null);
int indexBody = cursor.getColumnIndex( ReceptorSMS.BODY );
int indexAddr = cursor.getColumnIndex( ReceptorSMS.ADDRESS );
if ( cursor.moveToLast())return;
smsList.clear();
do
{
str = "Sender: " + cursor.getString( indexAddr ) + "\n" + cursor.getString( indexBody );
}
while( cursor.moveToPrevious());
Toast.makeText( this, str, Toast.LENGTH_LONG ).show();
}
感谢任何帮助