How to use Intents in an Android app?

Intents in Android are fundamental components that facilitate communication between different components of the application. They can be used to start activities, send broadcasts, or communicate with services. Below is an example of how to use Intents in an Android app to start a new activity.

To create and use an Intent, follow these steps:

  1. Create an instance of the Intent class.
  2. Use the startActivity() method to launch the activity.

Here’s a simple example of using an Intent to start a new activity:

// In your current activity Intent intent = new Intent(CurrentActivity.this, NewActivity.class); startActivity(intent);

Intents Android Intents start activity Android development Android app communication