How to create new activity in android studio

To create a new activity in Android Studio, follow these steps:

Method 1: Using the "New Activity" Wizard

  1. Open your Android project in Android Studio.
  2. In the project structure, navigate to the app directory.
  3. Right-click on the app directory and select "New" > "Activity" > "Empty Activity".
  4. Fill in the required information:
    • Activity name: Enter a name for your activity (e.g., "MainActivity").
    • Package name: Leave this field blank, as it will be automatically generated.
    • Save location: Choose a location to save your activity (e.g., app/src/main/java/com/example/yourapp).
    • Language: Select the programming language you want to use (e.g., Java or Kotlin).
  5. Click "Finish" to create the new activity.

Method 2: Using the "New" Menu

  1. Open your Android project in Android Studio.
  2. Go to the "File" menu and select "New" > "Activity" > "Empty Activity".
  3. Fill in the required information (same as above).
  4. Click "Finish" to create the new activity.

What happens next:

After creating the new activity, Android Studio will generate the necessary files and folders for your activity. You will see a new directory created under app/src/main/java with the same name as your activity (e.g., MainActivity.java or MainActivity.kt).

Tips and Variations:

That's it! You now have a new activity in your Android project.