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" > < 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