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.   Intent i = new Intent(MainActivity.this,SecondActivity.class); startActivity(i);   This line of code will make you screen move from main screen to second screen on clicking the button in first screen. startActivity(i) 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

 

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. And make  second screen as DEFAULT because first screen is LAUNCHER.

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.


 

Show Buttons
Hide Buttons