Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第一行代码 Android 179页 5.3章节 发送自定义广播代码遗漏 #31

Open
MonkSoul opened this issue Nov 3, 2018 · 1 comment

Comments

@MonkSoul
Copy link

MonkSoul commented Nov 3, 2018

在学习到第5.3章节 5.3.1 发送标准广播时发现书中代码只提供了发送标准广播的代码,没有提供监听代码,书中给出了...省略号,误以为不需要监听就可以了,调试了许久看了这里的源码才知道。

@YiAnCN
Copy link

YiAnCN commented Apr 22, 2019

不是有代码遗漏,是 Android 8.0 之后,对于广播的发送与接收变严格了,需要加入Component参数。

Intent intent = new Intent("com.example.broad");
intent.setComponent(new ComponentName("com.example.broadcasttest","com.example.broadcasttest.MyBroadcastReceiver"));
sendBroadcast(intent);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants