Quick Answer: How Do I Start a Second Activity on Android?
Contents

How do I start activity from another activity?

To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.

How do I add a second activity?

2.1 Create the second activity

  1. Click the app folder for your project and choose File > New > Activity > Empty Activity.
  2. Name the new activity “SecondActivity.” Make sure Generate Layout File is checked, and layout name will be filled in as activity_second.
  3. Click Finish.
Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest