当前位置: 代码迷 >> Android >> android: 最容易broadcast sample
  详细解决方案

android: 最容易broadcast sample

热度:233   发布时间:2016-05-01 15:15:02.0
android: 最简单broadcast sample
				//某个Activity某个按钮里发出broadcast				Intent intent = new Intent("test_broadcast");				sendBroadcast(intent);
		<!-- manifest的application里 -->		<receiver android:name=".MyBroadcastReceicer">			<intent-filter>				<action android:name="test_broadcast"></action>			</intent-filter>		</receiver>

?

?

?

import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.util.Log;//写一个 类接收Broadcastpublic class MyBroadcastReceicer extends BroadcastReceiver{	@Override	public void onReceive(Context arg0, Intent arg1) {		//接收到broadcast 总要干点什么吧		Log.d("bbbbbb", "-----------干点什么-------------");	}}

?这样一个最简单的broadcast就完成了

  相关解决方案