Android apk 今天在 三星24Ultra 这台机上报错
Caused by: java.lang.SecurityException: com.huawo.hawofit: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
针对这个问题去查资料,详见: Android14 registerReceiver注册广播时报错
其实就在registerReceiver函数的第三个参数写上RECEIVER_EXPORTED或者RECEIVER_NOT_EXPORTED
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
activity.registerReceiver(this, intentFilter, Context.RECEIVER_EXPORTED);
} else {
activity.registerReceiver(this, intentFilter);
}
这样就解决了,注销广播的方法不用改