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

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.