一、有序广播
1.代码实现
<receiver
android:name="bw.com.unit08.MyReceiver2"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="bw.com.yzh" />
</intent-filter>
</receiver>
<receiver
android:name="bw.com.unit08.MyReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="bw.com.yzh" />
</intent-filter>
</receiver>
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("bw.com.yzh");
intent.putExtra("name","杨子豪你好");
sendOrderedBroadcast(intent,null);
}
});
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals("bw.com.yzh")){
String name = intent.getStringExtra("name"