How to Create an Intent for an Activity

public Intent (Context packageContext, Class<?> cls) was added in API level 1
Create an intent for a specific component. All other fields (action, data, type, class) are null, though they can be modified later with explicit calls. This provides a convenient way to create an intent that is intended to execute a hard-coded class name, rather than relying on the system to find an appropriate class for you;
Parameters:
packageContext - A Context of the application package implementing this class.
cls - The component class that is to be used for the intent.

1. In the MainActivity.java file, add the below to the imports section.

import android.content.Intent;

2. Add the line below to the onCreate method. This will set an intent for the activity named MainActivity and set it to an intent named myIntent.

Intent myIntent = new Intent(this, MainActivity.class);