Crash Application using exception in Android

I just want to minimize the Android application and display the Force Close Dialog using Exception on Android. Is it possible? How it's done?

+6
source share
3 answers

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

 throw new RuntimeException("Crash!"); 
+16
source

try to put any erroneous statement in a try block, there are as many exceptions available as arithmetic , arrayindexoutofbounds , etc., then do what you want to do in catch.

And to display the Forceclose dialog box, you do not need to do something when you do not catch it by default. The force close dialog box appears.

And why catch exceptions when you want to minimize the application?

+1
source

I think you are looking for uncaughtExceptionHandler.

Here is a very good example

http://iamvijayakumar.blogspot.in/2012/09/android-uncaughtexceptionhandler.html

use this code in your activity to register an exception handler for inactive events,

 Thread.setDefaultUncaughtExceptionHandler(new UnCaughtException(MainActivity.this)); 
+1
source

All Articles