kandi background
Explore Kits

ANR-WatchDog | simple watchdog that detects Android ANR | Architecture library

 by   SalomonBrys Java Version: v1.0 License: MIT

 by   SalomonBrys Java Version: v1.0 License: MIT

Download this library from

kandi X-RAY | ANR-WatchDog Summary

ANR-WatchDog is a Java library typically used in Architecture applications. ANR-WatchDog has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.
[![Maven Central](https://img.shields.io/maven-central/v/com.github.anrwatchdog/anrwatchdog.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.anrwatchdog%22) [![MIT License](https://img.shields.io/github/license/salomonbrys/ANR-WatchDog.svg)](https://github.com/SalomonBrys/ANR-WatchDog/blob/master/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/SalomonBrys/ANR-WatchDog.svg)](https://github.com/SalomonBrys/ANR-WatchDog/issues) [![Donate](https://img.shields.io/badge/Backing-Donate-orange.svg)](https://donorbox.org/donation-salomonbrys/).
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • ANR-WatchDog has a medium active ecosystem.
  • It has 2163 star(s) with 354 fork(s). There are 95 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 7 open issues and 29 have been closed. On average issues are closed in 199 days. There are 1 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of ANR-WatchDog is v1.0
ANR-WatchDog Support
Best in #Architecture
Average in #Architecture
ANR-WatchDog Support
Best in #Architecture
Average in #Architecture

quality kandi Quality

  • ANR-WatchDog has 0 bugs and 0 code smells.
ANR-WatchDog Quality
Best in #Architecture
Average in #Architecture
ANR-WatchDog Quality
Best in #Architecture
Average in #Architecture

securitySecurity

  • ANR-WatchDog has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • ANR-WatchDog code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
ANR-WatchDog Security
Best in #Architecture
Average in #Architecture
ANR-WatchDog Security
Best in #Architecture
Average in #Architecture

license License

  • ANR-WatchDog is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
ANR-WatchDog License
Best in #Architecture
Average in #Architecture
ANR-WatchDog License
Best in #Architecture
Average in #Architecture

buildReuse

  • ANR-WatchDog releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • ANR-WatchDog saves you 20 person hours of effort in developing the same functionality from scratch.
  • It has 56 lines of code, 6 functions and 2 files.
  • It has low code complexity. Code complexity directly impacts maintainability of the code.
ANR-WatchDog Reuse
Best in #Architecture
Average in #Architecture
ANR-WatchDog Reuse
Best in #Architecture
Average in #Architecture
Top functions reviewed by kandi - BETA

kandi has reviewed ANR-WatchDog and discovered the below as its top functions. This is intended to give you an instant insight into ANR-WatchDog implemented functionality, and help decide if they suit your requirements.

  • Runs the ANR watchdog thread .
    • Sets the ANR interceptor .
      • Sets an ANR listener .
        • Sets the InterruptionListener .
          • Set the name prefix to use for reporting .
            • Sets whether to ignore debugging .
              • Sets whether threads to log .
                • Report all Threads
                  • Set the main thread .
                    • Gets the timeout interval .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      ANR-WatchDog Key Features

                      A simple watchdog that detects Android ANR (Application Not Responding) error and throws a meaningful exception

                      With Gradle / Android Studio

                      copy iconCopydownload iconDownload
                      ```
                      implementation 'com.github.anrwatchdog:anrwatchdog:1.4.0'
                      ```

                      Reading the ANRError exception report

                      copy iconCopydownload iconDownload
                      FATAL EXCEPTION: |ANR-WatchDog|
                          Process: anrwatchdog.github.com.testapp, PID: 26737
                          com.github.anrwatchdog.ANRError: Application Not Responding
                          Caused by: com.github.anrwatchdog.ANRError$_$_Thread: main (state = WAITING)
                              at testapp.MainActivity$1.run(MainActivity.java:46)
                              at android.os.Handler.handleCallback(Handler.java:739)
                              at android.os.Handler.dispatchMessage(Handler.java:95)
                              at android.os.Looper.loop(Looper.java:135)
                              at android.app.ActivityThread.main(ActivityThread.java:5221)
                          Caused by: com.github.anrwatchdog.ANRError$_$_Thread: APP: Locker (state = TIMED_WAITING)
                              at java.lang.Thread.sleep(Native Method)
                              at java.lang.Thread.sleep(Thread.java:1031)
                              at java.lang.Thread.sleep(Thread.java:985)
                              at testapp.MainActivity.SleepAMinute(MainActivity.java:18)
                              at testapp.MainActivity.access$100(MainActivity.java:12)
                              at testapp.MainActivity$LockerThread.run(MainActivity.java:36)

                      Timeout (minimum hanging time for an ANR)

                      copy iconCopydownload iconDownload
                      if (BuildConfig.DEBUG == false) {
                        new ANRWatchDog(10000 /*timeout*/).start();
                      }

                      Debugger

                      copy iconCopydownload iconDownload
                      new ANRWatchDog().setIgnoreDebugger(true).start();

                      On ANR callback

                      copy iconCopydownload iconDownload
                      new ANRWatchDog().setANRListener(new ANRWatchDog.ANRListener() {
                          @Override
                          public void onAppNotResponding(ANRError error) {
                              // Handle the error. For example, log it to HockeyApp:
                              ExceptionHandler.saveException(error, new CrashManager());
                          }
                      }).start();

                      Filtering reports

                      copy iconCopydownload iconDownload
                      new ANRWatchDog().setReportThreadNamePrefix("APP:").start();

                      ANR Interceptor

                      copy iconCopydownload iconDownload
                      new ANRWatchDog(2000).setANRInterceptor(new ANRWatchDog.ANRInterceptor() {
                          @Override
                          public long intercept(long duration) {
                              long ret = 5000 - duration;
                              if (ret > 0) {
                                  Log.w(TAG, "Intercepted ANR that is too short (" + duration + " ms), postponing for " + ret + " ms.");
                              }
                              return ret;
                          }
                      })

                      Problem with restarting the app, after an ANR event

                      copy iconCopydownload iconDownload
                      onCreate() 
                      FileLogger.setActivityName(this);
                      
                      /**to register the activity)
                      public static void setActivityName(Activity activityName){
                          anrActivity = activityName;
                      }
                      
                      /**This method is called by RestartUtil method to restart the app**/
                      public static void kill(){
                          if ( anrActivity != null) {
                              anrActivity.finish();
                              anrActivity.finishAffinity();
                          }
                          android.os.Process.killProcess(android.os.Process.myPid());
                      }
                      
                      onCreate() 
                      FileLogger.setActivityName(this);
                      
                      /**to register the activity)
                      public static void setActivityName(Activity activityName){
                          anrActivity = activityName;
                      }
                      
                      /**This method is called by RestartUtil method to restart the app**/
                      public static void kill(){
                          if ( anrActivity != null) {
                              anrActivity.finish();
                              anrActivity.finishAffinity();
                          }
                          android.os.Process.killProcess(android.os.Process.myPid());
                      }
                      
                      onCreate() 
                      FileLogger.setActivityName(this);
                      
                      /**to register the activity)
                      public static void setActivityName(Activity activityName){
                          anrActivity = activityName;
                      }
                      
                      /**This method is called by RestartUtil method to restart the app**/
                      public static void kill(){
                          if ( anrActivity != null) {
                              anrActivity.finish();
                              anrActivity.finishAffinity();
                          }
                          android.os.Process.killProcess(android.os.Process.myPid());
                      }
                      

                      Community Discussions

                      Trending Discussions on ANR-WatchDog
                      • Android: dalvik killing app due to ANR when in debugger breakpoint
                      • Problem with restarting the app, after an ANR event
                      Trending Discussions on ANR-WatchDog

                      QUESTION

                      Android: dalvik killing app due to ANR when in debugger breakpoint

                      Asked 2019-Mar-08 at 20:58

                      On an Android 4.3 embedded (custom) device, I am trying to debug my app by setting a breakpoint in a Service sub-class onStartCommand method. When I am paused at the breakpoint dalvik kills my app due to ANR not realizing that I am debugging.

                      The logcat shows:

                      W/ANRWatchdog: An ANR was detected but ignored because the debugger is connected (you can prevent this with setIgnoreDebugger(true))
                      I/dalvikvm: threadid=3: reacting to signal 3
                      D/dalvikvm: threadid=1: still suspended after undo (sc=1 dc=1)
                      I/dalvikvm: Wrote stack traces to '/data/anr/traces.txt'
                      Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'
                      

                      Notice that I have an ANRWatchDog in my app which correctly recognizes the debug session and ignores the ANR.

                      Is theer a way to do the same with Dalvik? I am assuming it is possible to debug a Service without crashing due to ANR.

                      ANSWER

                      Answered 2019-Mar-08 at 20:58

                      In developer settings, there is an option called "select debug app". Click on this and select the application you will be debugging. This should prevent any ANRs from occurring for that app, while you are debugging it. It also enables the "wait for debugger" option, which, if enabled, will pause the app as soon as it starts, so you can attach a debugger and debug the applications startup code, if necessary.

                      Source https://stackoverflow.com/questions/55070212

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install ANR-WatchDog

                      You can download it from GitHub, Maven.
                      You can use ANR-WatchDog like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the ANR-WatchDog component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

                      Support

                      For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Explore Related Topics

                      Share this Page

                      share link
                      Consider Popular Architecture Libraries
                      Try Top Libraries by SalomonBrys
                      Compare Architecture Libraries with Highest Support
                      Compare Architecture Libraries with Highest Quality
                      Compare Architecture Libraries with Highest Security
                      Compare Architecture Libraries with Permissive License
                      Compare Architecture Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.