BroadCastReceiver is a very important component in android.
if we want use this,how we do?
First,u need to create a class and let it extends BroadcastReceiver and to override it‘s onReceive function:
just like this:
package com.example.multidownload; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class OutCallReceive extends BroadcastReceiver{ @Override public void onReceive(Context arg0, Intent arg1) { // TODO Auto-generated method stub } }
Secondly, u need to change the Manifest.xml:
add a <receiver> between <application></application>:
<receiver android:name=".OutCallReceive"> <intent-filter> <action android:name="android.intent.action.NEW_OUTGOING_CALL"/> </intent-filter> </receiver>the action just like a listener.
maybe u need to add some permission:
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
the class‘s onReceive funciton will be called when the the action is happend。
we can use the getResultData() to get the data from the action.and we can use setResultData() to set the action Data.