A common requirement is to display the content on the interface when a new text message is sent. Content observer is used here. It is to let your program monitor text messages. If the content changes, you can get it. What I did on the text message side was that when his data changed, he told a public text message memory zone. He said, "My data has changed! Then, use the text message content provider to get the text message content to the public memory area, and your program will get it again. Here is a simple sample code:
ContentResolver resolver = getContentResolver (); Uri uri = Uri. parse ("content: // sms/"); resolver. registerContentObserver (uri, true, new MyObserver (new Handler (); Cursor cursor = resolver. query (uri, new String [] {"address", "date", "type", "body"}, null); cursor. moveToFirst (); String address = cursor. getString (0); String body = cursor. getString (3); System. out. println (address + "---" + body); cursor. close ();