FATAL EXCEPTION: MQTT Rec: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
I am getting fatal exception while receiving the data from MQTT I have changed my all legacy code to new code where I am passing RECEIVER_NOT_EXPORTED but still, I am facing the same issue.
ContextCompat.registerReceiver(this,mMessageReceiver,
new IntentFilter(AppConstants.INTENT_FILTERS.DASHBOARD_MESSAGE),
ContextCompat.RECEIVER_NOT_EXPORTED);
The same code is working fine in the below version of 14.
Can anyone please help me in this?
I have tried to pass RECEIVER_NOT_EXPORTED while registering Broadcast receiver but still, I am facing the same issue
Instead of using contextCompat use
thisif it is an activity or userequireContext()if it is a fragment.Then use it like this.
Make sure you import the correct one. You need to import the context one.
You can even add an sdk check.