自定义广播不进入onReceived方法

阅读 128

2022-08-05


根据资料,原来是Android8.0导致的。以前直接使用Intent设置action就可以了,现在要这样:

sendBroadcast(Intent(this@MainActivity, MyBroadcastReceiver::class.java)
.setAction("MY_BROADCAST"))

 

参考:

​​https://stackoverflow.com/questions/49197282/how-to-send-a-custom-broadcast-action-to-receivers-in-manifest?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa​​

精彩评论(0)

0 0 举报