Android Studio unhandled exception warnings

Issue

When I enter certain lines like JSONObject decoding or date parsing, the app will not compile as the compiler gives an UnhandledException warning and I have to wrap the call in a try/catch block before the app will compile. Can this be disabled so that I don’t need to write the try/catch block?

Solution

As I said in the comment doesn’t matter if you are using Android Studio or Eclipse or any other IDE, while using code which showing error where you should wrap your code with try / catch block, you can’t disable this. You should just add the block and change your code so you can handle the rest of your function or class properly if this exception is thrown in some point of program execution.

For throwing and catching exceptions in Java you can read more about here:

Java Programming : Throwing and Catching Exceptions

and for better explanation of which exceptions should be wrapped with try/catch block and which not, here are two good examples:

Java Exception Handling , and Java Exceptions

Answered By – hardartcore

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published