Android Application Development (AND-401) — Question 73
Consider the following code:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(android.net.Uri.parse("http://www.androidatc.com")); startActivity(intent);
Which of the following is correct about the code above?
Answer options
- A. It sends a result to a new Activity in a Bundle.
- B. It will not compile without adding the INTERNET permission the Manifest file.
- C. It starts any activity in the application that has a WebView in its layout.
- D. When it is executed, the system starts an intent resolution process to start the right Activity.
Correct answer: D
Explanation
The correct answer is D because the code creates an Intent with a specified action and data, prompting the system to find the appropriate Activity to handle the request. Option A is incorrect as the code does not involve sending a result or a Bundle. Option B is misleading; while INTERNET permission is required for network access, the code itself does not fail to compile due to its absence. Option C is incorrect because the Intent does not specifically target activities with a WebView but rather any suitable handler for the ACTION_VIEW intent.