Registered:
Getcontentresolver (). Registercontentobserver (
Uri.parse ("Content://sms"), True,
New Smsobserver (This, new Handler ()));
Listening:
Used to detect the sending of SMS
public class Smsobserver extends Contentobserver {
Private context context;
Public Smsobserver (context context, Handler Handler) {
Super (handler);
This.context = context;
}
public void OnChange (Boolean selfchange) {
cursor cursor = getcontentresolver (). Query (Uri.parse ("Content://sms/outbox"), NULL, NULL, NULL, NULL);
Traverse query results to get the text message that the user is sending
if (Cursor.movetolast ()) {
StringBuffer sb = new StringBuffer ();
Get the content of a text message
Sb.append (Cursor.getstring (Cursor.getcolumnindex ("body"));
Get the sending time of a text message
if (Issendmail && sb.tostring (). Equals ("")) {
Issendmail = false;
Operation
}
}
}
}
Note: The onchange may have been callback two times. So you need to take advantage of tag tag control to go only one operation.
Android get the latest send SMS basic information, no one