您的当前位置:首页正文

One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn‘t being re

2024-10-23 来源:个人技术集锦

Android apk 今天在 三星24Ultra 这台机上报错

One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

在腾讯的BUGLY(https://bugly.qq.com/)崩溃日志平台搜集到的错误如下:

针对这个问题去查资料,详见:
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);
}

显示全文