Exam AND-401 All QuestionsBrowse all questions from this exam
Question 101

Which of the following is a rule that developers must always follow when writing multi-threaded Android applications? (Choose two)

    Correct Answer: C, D

    In multi-threaded Android applications, it is crucial to follow certain rules to ensure the application performs efficiently and correctly. First, the UI thread must never be blocked because blocking it can make the application appear unresponsive to the user. Long operations, such as network access or database queries, should be performed in worker threads to keep the UI thread free to handle user interactions and drawing events. Second, the Android UI must not be accessed from outside the UI thread because the Android UI toolkit is not thread-safe. Accessing or manipulating UI components from a worker thread can lead to inconsistent states and unpredictable behavior. Therefore, all changes to the user interface must be done from the UI thread.

Discussion
MmadiOptions: CD

C. The UI thread must never be blocked. D. The Android UI must not be accessed from outside the UI thread.