'ANR - Input dispatching timed out - Android 11
My app gets ANR error only on android 11 devices. Input dispatching timed out means that main thread got stuck in a loop but based on my logcat trace what i understand is that there is a problem with file.exists() line.
Here is my logcat trace
at libcore.io.Linux.access (Native method)
at libcore.io.ForwardingOs.access (ForwardingOs.java:72)
at libcore.io.BlockGuardOs.access (BlockGuardOs.java:73)
at libcore.io.ForwardingOs.access (ForwardingOs.java:72)
at android.app.ActivityThread$AndroidOs.access (ActivityThread.java:7937)
at java.io.UnixFileSystem.checkAccess (UnixFileSystem.java:281)
at java.io.File.exists (File.java:815)
at com.****************.FileUtils.fileIsExists (FileUtils.java:17)
and here my FileUtlis.class
public class FileUtils {
public static boolean fileIsExists(String path) {
if (path == null || path.trim().length() <= 0) {
return false;
}
try {
File f = new File(path);
if (!f.exists()) {
return false;
}
} catch (Exception e) {
return false;
}
return true;
}
}
Solution 1:[1]
Put MANAGE_EXTERNAL_STORAGE flag in Manifest. Prompt user to allow all files access by opening the settings with ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION intent. Give that permission
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | hetvi patel |
