在这里插入代码片
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button =(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent =new Intent("com.example.broadcasttest.MY_BROADCAST");
// intent.setComponent(new ComponentName("com.example.broadcasttest", "com.example.broadcasttest.MY_BROADCAST"));
intent.setPackage("com.example.broadcasttest");
// sendBroadcast(intent);
//发送有序广播
sendOrderedBroadcast(intent,null);
// sendBroadcast(intent);
// intent.setPackage("com.example.broadcasttest2");
// sendOrderedBroadcast(intent,null);
}
});
intentFilter = new IntentFilter();
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
networkChangeReceiver = new NetworkChangeReceiver();
registerReceiver(networkChangeReceiver,intentFilter);
}
在安卓8.0之后,安卓发送广播不会弹出两次提示信息,通过设定setpackage后可以提出两次提示信息,可是却不能通过优先级阻断传播。请问一下各位大佬有什么妙招
安卓广播
最新推荐文章于 2024-07-24 22:20:44 发布