I have been working on an Android app which uses try/catch
frequently to prevent it from crashing even on places where there is no need. For example,
A view
It's definitely a bad programming practice.
From the current scenario, if there are hundreds of try
catch
like this, then you won't even know where the exception occurs without debugging the application, which is a nightmare if your application is in production environment.
But you can include a logger so that you get to know when an exception is throws (and why). It won't change your normal workflow.
...
try {
View view = findViewById(R.id.toolbar);
}catch(Exception e){
logger.log(Level.SEVERE, "an exception was thrown", e);
}
...