Android – Opening a new screen

  Opening a new screen is fairly easy in android. This post will show you almost all you need to know about switching back and forth between screens in your Android application. Add all activities to manifest Each screen is usually an Activity. Each activity should be mentioned in the manifest file. The simple use Bear in mind that every time you will call the function startActivity(intent) a new instance of MyActivity2 will be created. Passing a parameter In most times you need to pass a parameter to the new screen. You do that by using the function putExtra(). This function Receiving a parameter And of course you will need to receive that parameter on the other side. Going back If you need to go back to the previous screen and terminate the current screen, than all you have to do is to use the function finish() from anywhere in the new Activity. Open for result When you need to open a new screen and get result back from it, than use the function startActivityForResult() instead of startActivity() Returning a result Getting the result from the new activity