Launch a new activity. You will not receive any information about when the activity exits. This implementation overrides the base version, providing information about the activity performing the launch. Because of this additional information, the FLAG_ACTIVITY_NEW_TASK launch flag is not required; if not specified, the new activity will be added to the task of the caller.
Parameters: intent - The intent to start.
1. In the MainActivity.java file, in the onCreate method, Declare an Intent object named myIntent.
2. Now you need to set the intent to the activity you would like to open. Some examples are: Create an Intent to Open a New Activity/Screen, Set an Intent to Display the Android Device Location Settings Page
3. Add the below import to the imports section in the MainActivity.java file.
import android.content.ActivityNotFoundException;
4. In the MainActivity.java file, add the code below to the onCreate method.
try {
startActivity(myIntent);
} catch ( ActivityNotFoundException e) {
e.printStackTrace();
}
e.printStackTrace();
}
5. Compile and run!