Android Intercepting Outgoing Phone program example _android

Source: Internet
Author: User

Intercept and handle incoming calls:

The system emits an orderly broadcast when you make a call outside, although the broadcast will eventually be received by the broadcast receiver in the dial and the call is made, we can get the broadcast before the broadcast is delivered to the Dial broadcast receiver, and then clear the phone number that is passed to the recipient of the dialing broadcast. When the Dial broadcast receiver receives the broadcast, the phone call is canceled because the phone number is null.

Copy Code code as follows:

Intent Intent = new Intent (Intent.action_call,uri.parse ("tel:110"));
StartActivity (Intent);

Copy Code code as follows:

public class Outcallreceiver extends Broadcastreceiver {
public void OnReceive (context context, Intent Intent) {
Setresultdata (NULL); Clear the phone, the broadcast is passed to the receiver of the system, because the phone is null, cancel the call to dial
Also if you want to modify the dial phone number, you can do so
String phone = Getresultdata ()//Get Out call
Setresultdata ("12593" + phone), plus 12593 in front of the phone
}
}

Receive the dial-out telephone broadcast intent, subscribe to this intent in the <application> node of the Androidmanifest.xml file:

Copy Code code as follows:

<receiver android:name= ". Outgoingcallreceiver ">
<intent-filter android:priority= "1" >
<action android:name= "Android.intent.action.NEW_OUTGOING_CALL"/>
</intent-filter>
</receiver>

And to make a permission declaration:

Copy Code code as follows:

<uses-permission android:name= "Android.permission.PROCESS_OUTGOING_CALLS"/>

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.