Android Application Development (AND-401) — Question 20
What does this code do?
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(android.net.Uri.parse("http://www.androidatc.com")); startActivity(intent);
Answer options
- A. Starts a sub-activity
- B. Starts a service
- C. Sends results to another activity.
- D. Starts an activity using an implicit intent.
Correct answer: D
Explanation
The correct answer is D because the code creates an implicit intent to view a webpage. Option A is incorrect as it does not start a sub-activity, option B is wrong because it does not initiate a service, and option C is not applicable since it does not send results to another activity.