android | 静态注册广播接收器的坑
按书上写的并不能正常接收,查了一下是这个原因:
反正就是要加上包名类名,有点离谱哦。
具体如下:
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 发送广播
Log.d("Mz1", "click");
Intent i = new Intent("com.mz.test2023.MY_BROADCAST");
i.setComponent(new ComponentName("com.mz.test2023", "com.mz.test2023.NetworkChangeReceiver"));
sendBroadcast(i);
}
});
标签:接收器,test2023,静态,new,android,com,mz
From: https://www.cnblogs.com/Mz1-rc/p/17184015.html