Amitanshu Gupta
Amitanshu Gupta

Reputation: 111

ANR Input dispatching timed out (server) is not responding

In my Android application I am getting a very strange crash randomly. When I open the application I am fetching data from server on splash screen. When the application land on home page suddenly whole application is closed and here is what gets printed in the log:

ANR in com.test (com.test/.activities.SplashActivity)
    PID: 16020
    Reason: Input dispatching timed out (49abf6 com.test/com.test.activities.SplashActivity (server) is not responding. Waited 5004ms for FocusEvent(hasFocus=false))
Parent: com.test/.activities.SplashActivity
    Load: 29.87 / 30.79 / 30.77
    ----- Output from /proc/pressure/memory -----
    some avg10=0.00 avg60=0.00 avg300=0.00 total=3115344
    full avg10=0.00 avg60=0.00 avg300=0.00 total=1338179
    ----- End output from /proc/pressure/memory -----

Upvotes: 11

Views: 34225

Answers (2)

Gautam Wadhwani
Gautam Wadhwani

Reputation: 11

I encountered this issue when I was trying to make my foreground service wait for some duration. The fix was to use android.os.Handler. This will make the code inside the block run after delay_in_millis milliseconds and not make the entire service sleep (and then there was another error App isn't responding).

import android.os.Handler;

new Handler().postDelayed(new Runnable() {
    public void run() {
        // code to run after delay
    }
}, delay_in_millis);

Upvotes: 0

mabulazm
mabulazm

Reputation: 81

The cause of this exception is that UI thread is blocked and your application is not responding for more than 5 seconds.

Double check that the code fetching data from server is not executed on main thread. Also if you are using a braodcast receiver to do any logic that could take 10 seconds will lead to this issue.

Something else to check is the exception handling in the code fetching data from server.

You can take a look at the following page also: https://developer.android.com/training/articles/perf-anr.html#anr

Upvotes: 7

Related Questions