Is it possible to have a RuntimeException š« in your Android app and š»š¼š have it crash? š¤
- Nikolay Miroshnychenko

- Mar 1, 2024
- 1 min read
Yes, it is!
We can do this in two ways:
1. Via Thread.setDefaultUncaughtExceptionHandler š§µ which is a mechanism of Javaās Thread API. It allows us to catch an exception in the Thread that we have specified - if it was not caught beforehand.
2. Define a component in a separate process š. Defining a component to run in a separate process allows it to be independent of other components that run in distinct processes. Hence, when you have a crash in one process - it will not affect others.
How can we have a component that runs in a separate process?
By specifying the ššššššš:šššššššāattribute in our manifest like so:
<šššššššššššššš:šššš=".š¼š¢šššššššššæššššššššššššš"ššššššš:ššššššš=":šššššššš_ššššššš"ā/>Such service will launch in a separate process, making it independent of your application.
There are also other benefits to having components run in separate processes like:
- Improved security š
- Reduced memory usage š¾
- Reduced likelihood of the app / process being killed ā ļø
Do you use separate processes in your apps?






Comments