Advanced use of Intents: Android StartActivityForResult Example
In the previous tutorial Android Tutorial : Using Intent to move from one activity to another and sending data via putExtra , we saw the use of intent to move from one activity to another, today we will see how to receive a result from the second activity. The intent was instructed to call the second activity and through the startActivity method to display it. Imagine that our secondary activit y has a result to return to the first activity. Our objective is to start a second activity that returns result “data” to first activity. At first c reate a new Android Application. File >> New >> Android Application Enter Project name: StartActivity Keep other default selections, go Next until you reach Finish In your layout folder you must have two Layouts XML files. The first XML file "activity_main.xml" must contain a Button and the second XML file "second_activity.xml" must contain an EditText and a Button. res/