Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
77 views5 pages

Experiment 3 Part A A.1 AIM: - To Understand Intents and Its Methods in Android A.2 Prerequisite

This document describes an experiment on implementing intents in Android. It involves creating two activities such that the user can navigate between them. The first activity contains login fields and a button, and verifies credentials to start the second activity on button click using an intent. The code for the two activities and their layout files are provided. The conclusion states the experiment taught how to implement intents to move between activities in Android.

Uploaded by

Pronoy Debdas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views5 pages

Experiment 3 Part A A.1 AIM: - To Understand Intents and Its Methods in Android A.2 Prerequisite

This document describes an experiment on implementing intents in Android. It involves creating two activities such that the user can navigate between them. The first activity contains login fields and a button, and verifies credentials to start the second activity on button click using an intent. The code for the two activities and their layout files are provided. The conclusion states the experiment taught how to implement intents to move between activities in Android.

Uploaded by

Pronoy Debdas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment 3

PART A

A.1 AIM: - To understand Intents and its methods in Android


A.2 Prerequisite
Core Java (MCNB02001), Advanced Java (MCNB03002), Web Programming I
(MCNB03001),Web Programming II (MCNB04001)
A.3 Outcome
After successful completion of this experiment students will be able to
Create a UI (2 intents such that the user can freely move from one activity to other)

A.4 Theory/Procedure
1. Create a UI for Intents:
PART B
Roll No. A008 Name: Pronoy Debdas
Program: MCA Division:
Semester: Sem 5 Batch: B1
Date of Experiment: Date of Submission:
Grade :

B.1 Software Code written by student:

Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="127dp"
android:layout_marginTop="190dp"
android:onClick="loginclick"
android:text="Button"
tools:layout_editor_absoluteX="148dp"
tools:layout_editor_absoluteY="303dp" />

<EditText
android:id="@+id/ed1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/ed2"
android:layout_marginTop="16dp"
android:ems="10"
android:inputType="textPersonName" />

<EditText
android:id="@+id/ed2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="16dp"
android:layout_marginTop="84dp"
android:ems="10"
android:inputType="textPassword" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="39dp"
android:layout_marginTop="29dp"
android:text="Name" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/textView"
android:layout_alignTop="@+id/ed2"
android:text="Password" />
</RelativeLayout>

MainActivity.java
package com.example.pronoy.intent;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


EditText ed1,ed2;
Button b1;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ed1=(EditText)findViewById(R.id.ed1);
ed2=(EditText)findViewById(R.id.ed2);
b1=(Button)findViewById(R.id.b1);
}
public void loginclick(View view)
{

String s=ed1.getText().toString();
String p=ed2.getText().toString();

if(s.equals("aditya")&&p.equals("aditya"))
{
Toast.makeText(this,"login success",Toast.LENGTH_LONG).show();
Intent n=new Intent(MainActivity.this,Main2Activity.class);
startActivity(n);
}
else
{
Toast.makeText(this,"username passwords dont match",Toast.LENGTH_LONG).show();
}
}

}
Intent page

Activity_main2.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Main2Activity">

<TextView
android:id="@+id/textView3"
android:layout_width="241dp"
android:layout_height="77dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="96dp"
android:layout_marginTop="117dp"
android:text="A042"
android:textAppearance="@style/TextAppearance.AppCompat.Display3" />
</RelativeLayout>

Main2Activity.java
package com.example.pronoy.intent;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class Main2Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}
}
B.2 Input and Output:

B.3 Conclusion:

In this practical we learnt how to implement intents in Android.

You might also like