Create Second Activity

Photo by Sigmund on Unsplash

To create second activity, follow these steps:

  1. In the Project window, right-click app folder and select New > Activity > Empty Actvity.
  2. In the Configure Activity window, enter “DislayMessageActivity” for Activity Name. Leave all the other properties set to their defaults and click Finish.

Android Studio automatically does three things:

  • Create DisplayMessageActivity file.
  • Create the layout file activity_display_message.xml, which corresponds with the DisplayMessageActivity file.
  • Adds the required <activity> element in AndroidManifest.xml.

If you run the app and tap on the button on the first activity, the second activity starts but is empty. This is because the second activity uses the empty layout provided by the template.