Q3

Question 3

Create an application with first activity with an editText and send button. On click of send button, make use of explicit intent to send text to second activity and display there in text view.

App Insights:

Made layout for default main and secondary activity and added onCreate method, used EditText field and TextView to display the result using Explicit Intent.

Browse Source Code

Code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/linearlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <EditText
        android:id="@+id/editText"
        android:layout_width="150dp"
        android:layout_height="100dp"
        android:layout_weight="10"
        android:ems="10"
        android:inputType="textPersonName"
        android:paddingLeft="50dp"
        android:paddingTop="50dp"
        android:text="Enter any String" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="sendtext"
        android:text="send"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toStartOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>

Output

Studio Screenshot(Main Activity) (1/6)
App Screenshot(Main Activity) (2/6)
Studio Screenshot (Entering String Input) (3/6)
App Screenshot (Entering String Input) (4/6)
Studio Screenshot Displaying Desired Output (Secondary Activity) (5/6)
App Screenshot Displaying Desired Output (Secondary Activity) (6/6)

Last updated