I noticed something that seems a bit strange in Android: Calls to start an activity intent could throw an ActivityNotFound exception, if the expected app/handler is not installed, but there is no warning when coding this. When writing file reading/writing, network, etc. code, it usually gives a warning, you must either mark this function as “throws exception”, or add a try/catch for certain exceptions. Why are activity intents different?
Furthermore, if I mark a function as “throws ActivityNotFoundException”, I can still make a caller that doesn’t catch this error, it compiles fine and gives no warning. Why?
The reason no warning is given is because
ActivityNotFoundExceptionextendsRuntimeExceptionwhich does not have to be checked. The reason Google uses this is, as @Rocky Triton said, because it’s a massive pain for developers to have to check every single statement that could throw an exception. While Java discourages this, it still saves developers a huge hassle. (I even hate having to catch I/O exceptions…)