1、发送广播
使用Intent发送广告
Intent intent=new Intent();
intent.setAction("mybroadcast");
sendBroadcast(intent);
2.在xml注册广播接收者
<receiver android:name="mybroadcast" >
<intent-filter>
<action android:name="com.gs.My"
/>
</intent-filter>
</receiver>
2、接收广播
public class My extends BroadcastReceiver{
public void onReceive(Context context, Intent intent) {
System.out.println("接收");
}
}
原文:http://www.cnblogs.com/axiaoquana/p/3623807.html