0% found this document useful (0 votes)
36 views4 pages

Android Intent Programming Guide

The document outlines a practical assignment for T.Y.BSc(I.T) students at Maharashtra College, focusing on Android mobile programming. It includes code snippets for creating a main activity with an EditText and Button, and a second activity to receive and display data passed via an Intent. The assignment emphasizes understanding Intents, Events, Listeners, and Adapters in Android development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

Android Intent Programming Guide

The document outlines a practical assignment for T.Y.BSc(I.T) students at Maharashtra College, focusing on Android mobile programming. It includes code snippets for creating a main activity with an EditText and Button, and a second activity to receive and display data passed via an Intent. The assignment emphasizes understanding Intents, Events, Listeners, and Adapters in Android development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[Link](I.

T) SEM-VI Maharashtra College Advanced Mobile Programming

Practical 7

Programs on Intents, Events, Listeners and Adapters


The Android Intent Class, Using Events and Event Listeners

Create a new project and go to, activity_main.xml, and make the following additions to the code.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayoutxmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:id="@+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="132dp"
android:ems="10"
android:hint="Enter Data"
android:inputType="textPersonName" />

<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Send" />
</RelativeLayout>

Prof. Ansari Mohd. Shahid(7977-079-345 / 9821-77-1054) Page 1


[Link](I.T) SEM-VI Maharashtra College Advanced Mobile Programming

Main_Activity.java

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity {

EditText t1;
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
t1=(EditText)findViewById([Link].txt1);
b1=(Button)findViewById([Link].btn1);
[Link](new [Link]() {
@Override
public void onClick(View v) {
String data=[Link]().toString();
Intent intent=new Intent(getApplicationContext(),[Link]);
[Link]("data",data);
startActivity(intent);
}
});
}
}

Now create another activity Activity_data_receive.xml

Activity_data_receive.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayoutxmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DataRecieve">

Prof. Ansari Mohd. Shahid(7977-079-345 / 9821-77-1054) Page 2


[Link](I.T) SEM-VI Maharashtra College Advanced Mobile Programming

<TextView
android:id="@+id/tv1"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginStart="152dp"
android:layout_marginLeft="152dp"
android:layout_marginTop="161dp"
android:layout_marginEnd="132dp"
android:layout_marginRight="132dp" />
</RelativeLayout>

Data_Receive.java

package [Link];

import [Link];
import [Link];
import [Link];
import [Link];

public class DataRecieveextends AppCompatActivity {


TextViewt1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_data_recieve);
t1=(TextView)findViewById([Link].tv1);
Intent intent=getIntent();
String data=[Link]("data");
[Link](data);

}
}

Prof. Ansari Mohd. Shahid(7977-079-345 / 9821-77-1054) Page 3


[Link](I.T) SEM-VI Maharashtra College Advanced Mobile Programming

Output

Prof. Ansari Mohd. Shahid(7977-079-345 / 9821-77-1054) Page 4

You might also like