Professional Documents
Culture Documents
LAB 4 Manual
LAB 4 Manual
ACTIVITIES
List of Experiments
Understand the activity lifecycle, and when activities are created, pause, stop, and are
destroyed.
App Overview:
Create an App that can send a message from one screen to another using intents. Also the app
should be able to receive reply of an intent.
Note: onCreateMethod is already overrided by default when you create a new activity.
Task 4: Create a new method onSendButton in MainActivity.java, inside it create an intent and and
start the new activity using intent.
4.1. Create object of intent using current view, and explicitly describe the next java file to run.
Hint:
Intent in=new Intent(view.getContext(),SecondActivity.class);
startActivity(in);
4.4.Associate this function to the send Button in the xml file.
Hint:
<Button
android:layout_width="110dp"
android:layout_height="59dp"
android:text="Send"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Editable"
android:onClick="onSendButton"
/>
Task 4: Send the text from EditText to the second screen and display on the TextView.
Hint: In MainActivity.java inside onSendButton method, you need to add extra data inside intent
txt1=findViewById(R.id.Editable);
Hint: In MainActivity.java inside onCreate method, you need to get the intent, and get the Extras
from the intent.
Intent repylyintent=getIntent();
String reply=repylyintent.getExtras().getString("msg");
Hint: Goto AndroidManifest.xml file and find activity tag for SecondActivity and add a label to the
activity
Hint:
<activity android:name=".SecondActivity"
android:label="Second Screen"></activity>