Add a Second Activity using Intent in Android Studio

Reading Time: 3 minutes

When you want to add a second activity in Android Studio, perhaps best way is to do it by using Intent class. Once when you made your first android app as single activity apk, next natural thing is that you want to expand your android application. Good practice is to start your new many activity application as blank activity, and to make other activities as Google AdMob Ads Activity. On that way, first activity would have more space to put some control buttons to it, while later activities would have ads inserted. So late start our blank activity first:


Then you can get rid of the email icon at the bottom of your activity


Just go to app→res→layout→activity_main.xml and delete four lines of code as indicated in figure bellow.


Also, go to app→java→cirvirlab.activities→ and delete lines of code as indicated in figure bellow.


Next thing to do is to right click on app→java→cirvirlab.activities→ and add new activity


Advise is to choose Google AdMob Ads Activity so that we have some Google Ads on our second (and later) activities.

Add google Ad Activity as second Activity


This action will make necessary changes app→manifests→AndroidManifest.xml
Arrange you new activity like any other Google AdMob Ads Activity. Then put one button on your main activity so that you can navigate to second activity. Declare onClik event in text view of content_main.xml




android:text=”SECOND ACTIVITY”





android:layout_marginTop=”131dp” />


Also, put following code in file:

public void openSecond(View view)

Button button = (Button)view;

startActivity(new Intent(getApplicationContext(),Activity2.class));

This slice of code shows true power of using Intent class. Second activity appears when you press button.


External links:

Add a Second Activity by using Intent in Android Studio on

Tagged with: ,

Leave a Reply

Your email address will not be published. Required fields are marked *