0

I have an android Studio app trying to implement MQTT. The example I am modifying uses androidx.localbroadcastmanager.content.LocalBroadcastManager but it is deprecated. I am trying to replace this with something else but I can't find any good examples. Here is the code that I use.

build.gradle //(module)
dependencies {
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
}

in JavaClass

import androidx.localbroadcastmanager.content.LocalBroadcastManager;


  private void registerReceiver(BroadcastReceiver receiver) {
        IntentFilter filter = new IntentFilter();
        filter.addAction(MqttServiceConstants.CALLBACK_TO_ACTIVITY);
        LocalBroadcastManager.getInstance(myContext).registerReceiver(receiver, filter);
        receiverRegistered = true;
    }

This seems to be the only place it is used.

I'm sorry if what I have here isn't enough but I am new to this and could use a lot of help. Just let me know what more you need.

hardillb
  • 54,545
  • 11
  • 67
  • 105
user1114881
  • 731
  • 1
  • 12
  • 25

1 Answers1

0

I found that if I just remove the

LocalBroadcastManager.getInstance

from the code and use just

myContext.registerReceiver(receiver, filter);

it works just fine.

user1114881
  • 731
  • 1
  • 12
  • 25