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
}
}
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"/>
we can use the getResultData() to get the data from the action.and we can use setResultData() to set the action Data.
android BroadcastReceiver,布布扣,bubuko.com
原文:http://blog.csdn.net/howlaa/article/details/22898791