android BroadcastReceiver
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.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。