I want to read the message body of a new incoming SMS in android, programmatically.
I tried something but that doesn't return any contents:
Uri uri = Uri.parse("content://sms/inbox");
ContextWrapper context = null;
Cursor c = context.getContentResolver().query(uri, null, null ,null,null);
String body = null;
String number=null;
if(c.moveToFirst()) {
body = c.getString(c.getColumnIndexOrThrow("body")).toString();
number = c.getString(c.getColumnIndexOrThrow("address")).toString();
}
c.close();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…