Trainer sub-project (4) security guard-blacklist interception using content providers to delete call records and provider call records

Source: Internet
Author: User

Trainer sub-project (4) security guard-blacklist interception using content providers to delete call records and provider call records
In the previous section, we talked about deleting a call record, but a bug is that it will first appear in the call record, and then disappear, which is not good for the user experience, therefore, we need to use the content provider to observe the changes in the call records.

① Get a content manager first


getContentResolver().registerContentObserver(uri, true, new CallLogObserver( incomingNumber,new Handler()));

2. Then, you can assign a value to the Url through the calllog provided by the system.

Uri uri = Uri. parse ("content: // call_log/CILS"); you can also write CallLog. CILS. content_url is not written in this way. It is convenient for me to write a url directly.


③ Define an observer to perform operations.


Private class CallLogObserver extends ContentObserver {private String incomingNumber; public CallLogObserver (String incomingNumber, Handler handler) {super (handler); this. incomingNumber = incomingNumber;} @ Overridepublic void onChange (boolean selfChange) {Log. I (TAG, "the database content has changed, resulting in call records"); getContentResolver (). unregisterContentObserver (this); deleteCallLog (incomingNumber); super. onChange (selfChange );}}
Then, stop the call.
EndCall (); // The remote service method running in another process. After the method is called, the call record may not be generated yet.

That is, the method for hanging up the phone number written in the previous section.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.