首页 > 移动平台 > 详细

android BroadcastReceiver

时间:2014-04-04 01:41:25      阅读:553      评论:0      收藏:0      [点我收藏+]

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.


android BroadcastReceiver,布布扣,bubuko.com

android BroadcastReceiver

原文:http://blog.csdn.net/howlaa/article/details/22898791

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!