Intent has many uses like it is used to startActivity, services, different Broadcast intents which we will be covering in our coming tutorials.In this Android Tutorial on Intent we will be looking how to start a activity using intent in android.

In android apps generally user have to move through different screens as a part of app functionality.Clicking on a button will move us from one screen to another but we need to know how the coding is done for it.

We will see how the user moves from one screen to another what’s the programming involved. Before moving from one screen to another set both the screens with buttons to move to another screen and return back.

 

 

This line of code will make you start the intent which will result in screen move from main screen to second screen on clicking the button in first screen.

will start the intent.

 MainActivity.java

In firstscreen.xml add a textview and button. Clicking on button user moves to another screen.

 

firstscreen.xml

 

Now declare our Second activity i.e., SecondActivity.java under src.

SecondActivity.java

 

 secondscreen.xml

 

 

Note :

Now we have to declare our second activity in manifest file so that when we try to move it second screen should be initiated in manifest file.

Now add second screen to Android Manifest file

 

AndroidManifest.xml

Output :

intent1

If you have any query’s in this tutorial let me know through comments below.

Share this tutorial if you like it.

 

Show Buttons
Hide Buttons