novoda/merlin

onMerlinBind(com.novoda.merlin.NetworkStatus)' on a null object reference

medsafwentrabelsi opened this issue · 7 comments

Problem

 merlin = new Merlin.Builder().withConnectableCallbacks().build(MainActivity.this);
        merlin.registerConnectable(new Connectable() {
            @Override
            public void onConnect() {
                // Do something you haz internet!
                Toasty.info(MainActivity.this,"qqqqqq").show();
            }
        });
    protected void onResume() {
        super.onResume();
        result.closeDrawer();
        getAllCar();
        merlin.bind();



    }

Hi @medsafwentrabelsi, we are going to need some more information from you in order to be able to help.

Can you tell us:

  • The full stacktrace, where are you receiving this null pointer? I assume from the ConnectivityChangesForwarder?
  • Where are you instantiating your instance of merlin, is it onCreate? You haven't stated in the problem section.

Yes I instantiate it in oncreate() and i just add "merlin.bind();" in onResume()
But still I have the same problem

ok @medsafwentrabelsi I'll try and reproduce the issue and let you know if I need any more info. Thanks for raising.

Hi @medsafwentrabelsi this occurs because you need to register for bindable callbacks. You should be able to resolve the issue you are seeing by adding withBindableCallbacks onto the MerlinBuilder in onCreate.

Ideally, we avoid crashing in the event that a client has not added the withBindableCallbacks. Merlin should only respond to events that clients are interested in. Thanks for raising this issue @medsafwentrabelsi, I've created a new issue to capture the problem, here, please use the above workaround until a fix has been pushed to release.

@Mecharyry OK thank you very much just another thing it missing verification if the network does not have an internet access

@medsafwentrabelsi if you have any other problems can you please open another issue with a detailed description so that I can better assist you 😃

There is a suitable workaround for this issue, closing.