{"id":626,"date":"2019-11-03T11:45:31","date_gmt":"2019-11-03T01:45:31","guid":{"rendered":"https:\/\/learntodroid.com\/?p=626"},"modified":"2020-09-06T15:18:05","modified_gmt":"2020-09-06T05:18:05","slug":"how-to-switch-between-activities-in-android","status":"publish","type":"post","link":"http:\/\/10.0.0.14:32769\/how-to-switch-between-activities-in-android\/","title":{"rendered":"How to switch between Activities in Android"},"content":{"rendered":"\n

When making your Android apps you may get to the point where you need to create multiple Activities for different screens within your app. When you have multiple Activities you will need a way to transition between them in a way that doesn’t break the back button functionality.<\/p>\n\n\n\n

In order to switch between Activities in Android you will need to follow these steps:<\/strong><\/p>\n\n\n\n

  1. Create the Activities<\/strong><\/li>
  2. Add the Activities to the app’s Manifest<\/strong><\/li>
  3. Create an Intent referencing the Activity class you want to switch to<\/strong><\/li>
  4. Call the startActivity(Intent) method to switch to the Activity<\/strong><\/li>
  5. Create a back button on the new Activity and call the finish() method on an Activity when the back button is pressed<\/strong><\/li><\/ol>\n\n\n\n

    I have created sample code below also available on GitHub<\/a> showing how to transition between Activities. <\/p>\n\n\n\n

    A video version of this tutorial is available on YouTube which I have also embedded below.<\/p>\n\n\n\n

    \n
    https:\/\/www.youtube.com\/watch?v=UyyZdXVCvLs<\/a>