You will need to set certain permissions (see the link below), but here is a sample code to use Cursorto retrieve the first SMS message.
Uri uri = Uri.parse("content://sms/inbox");
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();
FrontPage/Tutorials/SMS Messaging - Wiki Mobdev, SMS Android.
EDIT:
, Activity. . , , .
, onUpdate Context, Activity, Context getContentResolver (. )
startManagingCursor , , Activity Cursor .
, - .
2:
AndroidManifest.xml , - , .
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>