I had my singleton class initially like this
 private static MqttHandler instance = new MqttHandler();
 private MqttHandler(){};
 public MqttHandler getInstance(){
    return instance;
 }
Now in one phone it was working as expected, but in another, seems like it was creating many instances, since whenever I tried to log something, it did log multiple times. I have no idea why. The second time I tried using this
  private MqttHandler instance;
  private MqttHandler(){};
  public MqttHandler getInstance(){
      if(instance==null) instance == new MqttHandler();
      return instance;
  }
Seems to be working, at least for now, not sure if its going to crash later, Does this mean that, in my first method, whenever I returned instance, it was calling
 new MqttHandler();
thus creating new instances all the time? Why would it work on one device correctly, and then refuse completely on a different one?
 
     
    