自定义广播不进入onReceived方法

根据资料,原来是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

猜你喜欢

转载自jameskaron.iteye.com/blog/2419836
今日推荐