Take the 2-minute tour ×

How i can display custom error message before foreclose or Application not responding message will happen for an application.


Can i display Custom message like "Please wait....." instead of Application not responding message.

Thank you

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You have to make sure you are handling any exceptions that are thrown. That is what causes a force close, an uncaught exception. as for the "not responding" message, again, this is up to the developer. You need to spawn new threads and do async tasks, that way processing does not block the main thread, which is what the UI runs on. When the main thread is blocked, that is when the "not responding" message happens. If you spawn a new thread, then you can display what ever kind of message you want to the user to notify them that something is processing.

share|improve this answer
I understand your explanation. Thank you For reply Ryan. –  praveenb Aug 11 '10 at 23:06
add comment

I'll add to Ryan's answer that you can handle all critical exceptions without the need to wrap most of your code in try-catch. There is a beautiful method for that: Thread.setDefaultUncaughtExceptionHandler. It is mainly useful for bug reporting. For the purpose of showing a message you have to set the handler in Application.onCreate (you'll have to set <application>'s android:name in the manifest to your custom Application class), save the application context and then use it to show a notification in the status bar - it remains after your application has been force closed. Also, in order to have the Force Close dialog appear instead of just freezing after your exception handler has worked, you should call defaultHandler = Thread.getDefaultUncaughtExceptionHandler(); in the handler's constructor and then in the end of public void uncaughtException(...) call defaultHandler.uncaughtException(thread, ex);.

share|improve this answer
Hi , can u please share a piece of code ... –  Mohit Sharma Jul 3 '12 at 7:32
@MohitSharma Here you are: pastebin.com/2bm3dUWE –  Psycho Jul 3 '12 at 13:49
add comment

Your Answer


