top of page

Is it possible to have a RuntimeException 🚫 in your Android app and š—»š—¼š˜ have it crash? šŸ¤”




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?

Ā 
Ā 
Ā 

Recent Posts

See All

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

©2025 by Mykola Miroshnychenko

bottom of page