Which of the following lines of code starts activity Activity2 from a current activity Activity1?
Which of the following lines of code starts activity Activity2 from a current activity Activity1?
To start Activity2 from the current activity Activity1, the correct line of code is `Intent intent = new Intent(this, Activity2.class); startActivity(intent);`. This code correctly creates an Intent object with the context of the current activity (this) and the class of the activity to start (Activity2.class), and then it starts the activity using the startActivity(intent) method. Option D only includes the Intent creation part, and even though the startActivity(intent) method is not explicitly mentioned here, it is implied as part of the process.
D. Intent intent = new Intent(this,Activity2.class);