Why is startActivity() wrapped in try/catch in this lab?
- To log the URL
- To avoid a crash (ActivityNotFoundException) if no app can handle the intent
- To speed up the app
- To ask for permissions
Answer
B) To avoid a crash (ActivityNotFoundException) if no app can handle the intent
Catching the exception lets the app show a friendly message instead of crashing.
Computer Science MCQ · More Lab: Implicit Intents – Browser and Dialer MCQs · Practise