长话短说~
1.发送
//广播动作,我是写的接收的activity public static final String ACTION = "cn.titansys.xview_pptv.player.PlayerActivity";
private void SendBroadcast(String str){
Intent intent = new Intent(SSDPConstants.ACTION);
intent.putExtra("_CONTROL",str);
myactivity.sendBroadcast(intent);
}
2.接收
在protected void onCreate(Bundle savedInstanceState) {里面初始化一下就行,是正常可以收到的,只是用于单向传递数据,够用
private void InitBroad(){
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("接收的参数",intent.getStringExtra("_CONTROL"));
//
}
};
registerReceiver(receiver,new IntentFilter(SSDPConstants.ACTION));
}