Home » Android » java – Crash An App using Exception in Android

java – Crash An App using Exception in Android

Posted by: admin June 15, 2020 Leave a comment


I just want to crash an Android application and display the “Dialog of Death” (Force Close Dialog) using Exception in Android. Is it possible? How is it done?

How to&Answers:

What you want is a RuntimeException, since the compiler will otherwise force you to move your code inside a try-catch block.

throw new RuntimeException("Crash!");


I think you are looking for uncaughtExceptionHandler.

Here is a very good example,


use this code in your Activity to register a Uncaught Exception Handler,

Thread.setDefaultUncaughtExceptionHandler(new UnCaughtException(MainActivity.this));


try to put any erroneous statement in try block, there are so many exceptions available like arithmetic ,arrayindexoutofbounds and so on then do what you want to do in catch.

And for displaying forceclose dialog, you need not to do something when you don’t catch it by default the force close dialog appears.

And why to catch the exception when you want to crash the app?