Coder Social home page Coder Social logo

Comments (6)

pwittchen avatar pwittchen commented on August 25, 2024

Can you provide code, which caused this error? It will be much more easier to reproduce this bug and fix it. Without that, it's quite hard.

In your error, we can see message Are you missing a call to unregisterReceiver()?, but receiver is unregistered in unsubscribe() method. Probably something is messed with Context or threads used in RxJava subscription.

Where do you call unsubscribe() method? It should be called in onPause() method in your Activity. If you call it somewhere else or don't call it at all, this error may occur.

from reactivenetwork.

carstenbaumhoegger avatar carstenbaumhoegger commented on August 25, 2024

Sure, here's the code, I'm using, hope this helps.

This is the method that does the subscription

    private void checkWifiConnection() {
        mWifiSubscription = new ReactiveNetwork().observeConnectivity(mActivity)
                .observeOn(Schedulers.io())
                .subscribeOn(Schedulers.io())
                .subscribe(connectivityStatus -> {
                    if(connectivityStatus == ConnectivityStatus.WIFI_CONNECTED) {
                        Log.w(TAG, "wifi connected!");
                        hasWifi = true;
                        if(!isConnected) {
                            establishConnection();
                        }
                    } else {
                        Log.w(TAG, "wifi not connected! " + connectivityStatus);
                        hasWifi = false;
                    }
                });
    }

And here I call unsubscribe

    public void closeConnection() {
        mWifiSubscription.unsubscribe();
        mActivity.finish();
    }

from reactivenetwork.

pwittchen avatar pwittchen commented on August 25, 2024

Thanks!
I have a few more questions. Where do you call checkWifiConnection() method and closeConnection() method? You've written in the first post that these methods are not located in the Activity. How do you call these methods from your Activity? I need to know more details to reproduce this bug. It may be incorrect library usage. I'm asking all these questions to clarify this issue.

from reactivenetwork.

carstenbaumhoegger avatar carstenbaumhoegger commented on August 25, 2024

checkWifiConnection() get's called in the Activities onResume() method and closeConnection() is called in onPause().
Could be wrong lib usage, but I don't know, what mistake I'm making here :D

from reactivenetwork.

carstenbaumhoegger avatar carstenbaumhoegger commented on August 25, 2024

Okay, I rewrote a few parts of the code and re-located the method calls and now it seems to work without the error.
My fault, sorry that I bothered you with it.
Great lib, keep up the good work!

from reactivenetwork.

pwittchen avatar pwittchen commented on August 25, 2024

Great! I'm glad you found source of the problem and fixed it. :-)

from reactivenetwork.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.