Reputation: 1585
Edit: As pointed out in the comments by ducknbear, there seems to be a workaround described here. I am not into Android dev anymore, please take your own look.
Original Question: I am quite new to Android and have a debugging issue. I know what an ANR is for, and do not see them when I run my app normally. However, when I try to debug my BoradcastReceiver, I am too slow and get the ANR message.
Is there a way to switch off ANR during debug sessions? I could use log statement to see what's happening, but this is annoying....
edit: actually, I don't want to supress the ANRs in the LogCat, I want to tell android not to throw ANRs during debugging. I mean to allow Broadcast receivers to take longer than 5 seconds to run. But I guess it will not be possible and instead I should delegate to a service, which is allowed to run longer, which I also can debug easier.
Thanks in advance!
greets
Upvotes: 31
Views: 11901
Reputation: 5316
You may find this resource useful for your problem. Key points:
adb shell am clear-debug-app your.app.package
to undo --persistentUpvotes: 2
Reputation: 539
Go to Settings -> Developer options and check Show all ANRs.
This will show an App Not Responding dialog for apps running in the background. You can click the Wait button in the dialog to prevent the system from killing your process. Note that the dialog is opened automatically for apps running in the foreground. For background apps, you have to enable this option.
Upvotes: 15
Reputation: 36289
No. This message is handled through the Android OS, not your application, and there is no way to hide it on the Emulator. If you don't want to see it and your BroadcastReceiver
receives the call correctly, just doesn't run successful code, you can use a try-catch block, and instead of your application crashing, the catch will be handled, wherein you can make a Toast message or whatever you wish.
Upvotes: 0