SMS bug of android content observer,
Steps:
1. Get the content observer ContentResolver contentResolver = getContentResolver ();
2. Register and observe the observed content (that is, add the observer in the android text message)
// Uri Short Message Address // true indicates that the SMS address meets the requirements. false indicates that the Message address must be exactly the same. // Add the observer. What is the Uri uri = Uri. parse ("context: // sms/"); // sms contentResolver. registerContentObserver (uri, true, new MyObserver (new Handler (); 3. specific observer private class MyObserver extends ContentObserver {
Public MyObserver (Handler handler) {super (handler );}
/*** This method is called when the content observes that the database has been updated * that is, it will be known when a new text message is updated */
@ Overridepublic void onChange (boolean selfChange) {super. onChange (selfChange); Toast. makeText (MainActivity. this, "message content prompts", Toast. LENGTH_SHORT ). note: In the onChange () method, you can write some text message content, send it to your server, and send a message to yourself from the server, in this way, the text message is eavesdropped, but the user's privacy is Snoop, so you don't mind using it.