My Demo application consists of 2 activities
- MainActivity
- newactivity
Content:
In MainActivity, there is layout which contains, a Text View to display 'Activity 1. and an Edit Text to enter the text which you will be transferring to new_activity. and a 'click me' Button on click of which, the second activity should start with the data in the edit text packed and sent to the second activity through an intent.
Code for the Java class 'MainActivity.java' is as follows,
Code for the Layout of MainActivity - 'activity_main.xml' is as follows,
In new_activity, there is a Text View which will display the data received from the MainActivity. and a 'Send back the data' button, on click of which "Data successfully returned" string is sent back to the MainActivity and is displayed in the Edit Text. (this is receiving data)
Code for the Java class 'newactivity.java' is as follows,
Code for the Layout of new_activity - 'activity_newactivity.xml' is as follows,
Some Functions used in the code and its brief explanation:
- PutExtra(String id, value):
- StartActivityforResult(Intent, Request_code)
- OnActivityResult(int request_code, int result_code, Intent data)
- setResult(RESULT_CODE, RESULT_INTENT)
- finish()
Watch the video demonstration at my YouTube channel.
Queries will be cleared if comments are dropped. ;)





