Getting started with Android: Broadcast receiver application (phone blocker)

Source: Internet
Author: User
1. Application description of the telephone interceptor


When we enter the phone number and make a call, the system will issue an ordered broadcast (Action = "android. intent. action. new_outgoing_call "), which is expected to be sent to the broadcast receiver of the phone dial application. However, we can set a higher priority interceptor broadcast receiver (Android: Priority =" 1000 "), this allows the caster to clear the phone number before receiving the phone number ,:

Because this application should be concealed, it needs to be started on its own. When it is started on its own, the system will send a broadcast to activate components that meet the conditions (Action = "android. intent. action. boot_completed ");

II, Code Implementation

Androidmanifest. xml

<Uses-Permission Android: Name = "android. Permission. process_outgoing_cils"/> <! -- External dialing permission --> <uses-Permission Android: Name = "android. Permission. receive_boot_completed"/> <! -- Receive boot broadcast --> <application Android: icon = "@ drawable/ic_launcher" Android: Label = "@ string/app_name"> <er Android: Name = ". phonebroadcastreceiver "> <intent-filter Android: Priority =" 1000 "> <action Android: Name =" android. intent. action. new_outgoing_call "/> <action Android: Name =" android. intent. action. boot_completed "/> </intent-filter> </receiver> </Application>

Phonebroadcastreceiver. Java

Package COM. xiazdong. phonelistener; import android. content. broadcastreceiver; import android. content. context; import android. content. intent; public class phonebroadcastreceiver extends broadcastreceiver {@ overridepublic void onreceive (context, intent) {If ("5556 ". equals (this. getresultdata () This. setresultdata (null); // if the phone number is 5556, it is cleared and cannot be called }}

Related Article

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.