Giter Site home page Giter Site logo

Comments (5)

SalomonBrys avatar SalomonBrys commented on July 20, 2024

ANR-Watchdog does not makes any check at startup. If you call start() on it, it will start.

That comment refers to the proposed usage in README:

if (!BuildConfig.DEBUG) {
    new ANRWatchDog().start();
}

If you still want the watchdog enabled in debug when the debugger is not connected, simply changes this for:

if (!Debug,isDebuggerConnected()) {
    new ANRWatchDog().start();
}

Be aware, however, that should you attach a debugger after startup, the watchdog will interpret debug pauses as ANRs.
To prevent this, you could set an ANRListener:

new ANRWatchDog().setANRListener(new ANRWatchDog.ANRListener() {
    @Override
    public void onAppNotResponding(ANRError error) {
        if (!Debug,isDebuggerConnected())
            throw error;
    }
}).start();

from anr-watchdog.

TWiStErRob avatar TWiStErRob commented on July 20, 2024

Yep, I understand all that. I'm proposing to use the last code block (if-throw) in the core of the library so it's handled automatically for everyone by default without the need for configuration.

It would also simplify basic library usage to one code line and no caveats.

from anr-watchdog.

SalomonBrys avatar SalomonBrys commented on July 20, 2024

That's a good idea ;)

There would have to be an option to revert to previous behaviour.

I'll work on that ;)

from anr-watchdog.

HolenZhou avatar HolenZhou commented on July 20, 2024

new ANRWatchDog().setANRListener(new ANRWatchDog.ANRListener() {
@OverRide
public void onAppNotResponding(ANRError error) {
if (!Debug,isDebuggerConnected())
throw error;
}
}).start();

I think this code should be the basic use, it meets all requirements.

from anr-watchdog.

SalomonBrys avatar SalomonBrys commented on July 20, 2024

Done in 1.2.0.
Thanks for the report :)

from anr-watchdog.

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.