Android-Intercept outbound calls

Source: Internet
Author: User

Reprint Please specify source: http://blog.csdn.net/l1028386804/article/details/46993859

Here, we briefly introduce the method of intercepting the outgoing calls through Broadcastreceiver.

1. Create phonereceiver inherit from Broadcastreceiver

This class is a subclass of Broadcastreceiver, the specific interception operation implemented in this class, I am here just a simple introduction to the method, the acquisition of the external dial number to print out. The specific business logic will have to be achieved by all themselves.

The specific code is as follows:

Package Com.lyz.rereiver;import Android.content.broadcastreceiver;import Android.content.context;import Android.content.intent;import android.util.log;/** * Intercept Outgoing calls * @author Liuyazhuang * */public class Phonereceiver extends B Roadcastreceiver {private static final String TAG = "Phonereceiver"; @Overridepublic void OnReceive (context context, Inten T intent) {//TODO auto-generated method stubstring num = Getresultdata (); LOG.I (TAG, num);}}
2, in the Androidmanifest.xml file to register the appropriate authorization information

The specific implementation is as follows:

<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "package=" Com.lyz.phone "android:versioncode=" 1 "android:versionname=" 1.0 "> <uses-sdk an droid:minsdkversion= "8" android:targetsdkversion= "/><"!--intercept outbound call authorization--<uses-permission android:n Ame= "Android.permission.PROCESS_OUTGOING_CALLS"/> <application android:allowbackup= "true" android:i con= "@drawable/ic_launcher" android:label= "@string/app_name" android:theme= "@style/apptheme" > &lt            Activity android:name= "com.lyz.phone.MainActivity" android:label= "@string/app_name" > <intent-filter> <action android:name= "Android.intent.action.MAIN"/> <catego                 Ry android:name= "Android.intent.category.LAUNCHER"/> </intent-filter> </activity>    <!--configure broadcast intercept outside dial-up    <receiver android:name= "Com.lyz.rereiver.PhoneReceiver" > <intent-filter android:priority= "$"                ; <action android:name= "Android.intent.action.NEW_OUTGOING_CALL"/> </intent-filter> </recei Ver> </application></manifest>
Is it easy to do it?

Warm tip: You can download the complete sample code to the HTTP://DOWNLOAD.CSDN.NET/DETAIL/L1028386804/8921101 link

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android-Intercept outbound 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.