SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
PRACTICAL-2
A. Create “hello world” application. That will display “Hello World” in the middle of the
screen in the black color with wheat color or white background.
B. create hello world using java
HelloMainActivity.java
package com.example.raj.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Activity_hello_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#fafad2"
tools:context="com.example.raj.myapplication.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Hello World"
android:textSize="30sp"
android:textColor="#B22222"
android:layout_centerVertical="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
android:layout_marginTop="99dp" />
</RelativeLayout>
Output:
B. Create hello world using java
package com.example.raj.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView text = new TextView(this);
text.setText("Hello World");
setContentView(text);
}
}
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
Output:
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
PRACTICAL-3
Create an Android App Which Has one Activity to get two numbers N1 and N2.on pressing
Button has four operation Add, Multiply, Divide, Subtract ,on select any one operation it
will Display Result in Text View of Activity
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#fafad2"
tools:context="com.example.raj.myapplication.MainActivity"
android:weightSum="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="No 1:"
android:id="@+id/tv1" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etno1"
android:ems="10"
android:hint="Enter No1"
android:inputType="number"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="No 2:"
android:id="@+id/tv2" />
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etno2"
android:ems="10"
android:hint="Enter No2"
android:inputType="number"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Result is"
android:id="@+id/tv3"
android:layout_gravity="center" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="+"
android:id="@+id/Add" />
<Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="-"
android:id="@+id/Sub" />
<Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="*"
android:id="@+id/Mul" />
<Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="/"
android:id="@+id/Div" />
</LinearLayout>
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
</LinearLayout>
</LinearLayout>
MainActivity.java
package com.example.raj.myapplication;
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.TextView;
public class MainActivity extends AppCompatActivity {
TextView tv1, tv2, Result;
EditText et1, et2;
Button Add, Sub, Mul, Div;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1 = (EditText)findViewById(R.id.etno1);
et2 = (EditText)findViewById(R.id.etno2);
Result = (TextView)findViewById(R.id.tv3);
Add = (Button)findViewById(R.id.Add);
Sub = (Button)findViewById(R.id.Sub);
Mul = (Button)findViewById(R.id.Mul);
Div = (Button)findViewById(R.id.Div);
Add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//TODO Auto-Generated Method...
if(et1.getText().toString().equals(""))
{
et1.setError("Please fill the No1");
}
else if(et2.getText().toString().equals(""))
{
et2.setError("Please fill the No2");
}
else
{
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
int a = Integer.parseInt(et1.getText().toString());
int b = Integer.parseInt(et2.getText().toString());
int c = a + b;
Result.setText("Answer="+c);
}
}
});
Sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//TODO Auto-Generated Method...
if(et1.getText().toString().equals(""))
{
et1.setError("Please fill the No1");
}
else if(et2.getText().toString().equals(""))
{
et2.setError("Please fill the No2");
}
else
{
int a = Integer.parseInt(et1.getText().toString());
int b = Integer.parseInt(et2.getText().toString());
int c = a - b;
Result.setText("Answer="+c);
}
}
});
Mul.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//TODO Auto-Generated Method...
if(et1.getText().toString().equals(""))
{
et1.setError("Please fill the No1");
}
else if(et2.getText().toString().equals(""))
{
et2.setError("Please fill the No2");
}
else
{
int a = Integer.parseInt(et1.getText().toString());
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
int b = Integer.parseInt(et2.getText().toString());
int c = a * b;
Result.setText("Answer="+c);
}
}
});
Div.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//TODO Auto-Generated Method...
if(et1.getText().toString().equals(""))
{
et1.setError("Please fill the No1");
}
else if(et2.getText().toString().equals(""))
{
et2.setError("Please fill the No2");
}
else
{
int a = Integer.parseInt(et1.getText().toString());
int b = Integer.parseInt(et2.getText().toString());
int c = a / b;
Result.setText("Answer="+c);
}
}
});
}
}
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
OUTPUT:
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
PRACTICAL-4
Create application for demonstration of android activity life cycle.
Activity_life_cycle.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.raj.lifecycle.LifeCycle">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Android Activity Life Cycle"
android:id="@+id/tv1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
LifeCycle.java
package com.example.raj.lifecycle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class LifeCycle extends AppCompatActivity {
TextView tv1;
String text;
@Override
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_life_cycle);
tv1 = (TextView)findViewById(R.id.tv1);
text = tv1.getText().toString();
text = text + "n InsideCreate Method";
tv1.setText(text);
}
public void onStart()
{
super.onStart();
text = tv1.getText().toString();
text = text + "n InsideStart Method";
tv1.setText(text);
}
public void onRestart()
{
super.onRestart();
text = tv1.getText().toString();
text = text + "n InsideRestart Method";
tv1.setText(text);
}
public void onResume()
{
super.onResume();
text = tv1.getText().toString();
text = text + "n InsideResume Method";
tv1.setText(text);
}
public void onPause()
{
super.onPause();
text = tv1.getText().toString();
text = text + "n InsidePause Method";
tv1.setText(text);
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
}
public void onStop()
{
super.onStop();
text = tv1.getText().toString();
text = text + "n InsideStop Method";
tv1.setText(text);
}
public void onDestroy()
{
super.onDestroy();
text = tv1.getText().toString();
text = text + "n InsideDestroy Method";
tv1.setText(text);
}
}
OUTPUT:
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
PRACTICAL-5
Create Registration page to demonstration of Basic widgets available in android.
Activity_widgetdemo.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.raj.widgetdemo.widgetdemo">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Registration"
android:id="@+id/tv1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Name:"
android:id="@+id/tv2"
android:layout_below="@+id/tv1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="37dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Mobile No:"
android:id="@+id/tv3"
android:layout_below="@+id/tv2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
android:layout_marginTop="39dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/et1"
android:layout_above="@+id/tv3"
android:layout_alignLeft="@+id/tv1"
android:layout_alignStart="@+id/tv1"
android:ems="10"
android:hint="name"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/et2"
android:layout_alignTop="@+id/tv3"
android:layout_alignLeft="@+id/et1"
android:layout_alignStart="@+id/et1"
android:ems="10"
android:hint="mobile no"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Cast:"
android:id="@+id/tv4"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/et2"
android:layout_alignLeft="@+id/et2"
android:layout_alignStart="@+id/et2"
android:id="@+id/radioGroup">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="General"
android:id="@+id/rb1"
android:checked="false" />
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SEBC"
android:id="@+id/rb2"
android:checked="false" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SC"
android:id="@+id/rb3"
android:checked="false" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ST"
android:id="@+id/rb4"
android:checked="false" />
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Language:"
android:id="@+id/tv5"
android:layout_below="@+id/radioGroup"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="37dp" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gujarati"
android:id="@+id/chk1"
android:checked="false"
android:layout_alignBottom="@+id/tv5"
android:layout_alignLeft="@+id/btn"
android:layout_alignStart="@+id/btn" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hindi"
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
android:id="@+id/chk2"
android:checked="false"
android:layout_alignTop="@+id/chk1"
android:layout_toRightOf="@+id/tv1"
android:layout_toEndOf="@+id/tv1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SUBMIT"
android:id="@+id/btn"
android:layout_alignLeft="@+id/radioGroup"
android:layout_alignStart="@+id/radioGroup"
android:layout_below="@+id/chk1"
android:onClick="submit"/>
</RelativeLayout>
widgetdemo.java
package com.example.raj.widgetdemo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class widgetdemo extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_widgetdemo);
}
public void submit(View v)
{
Toast.makeText(this,"You have Registered successfully.",Toast.LENGTH_LONG).show();
}
}
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
OUTPUT:
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
PRACTICAL-6
Create sample application with login module. (Check username and password) on
successful login, change Text view “Login Successful.” And on failing login, alert user using
Toast “Login fail.”
Activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.raj.loginpage.login"
android:background="#f0dfc9">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Login Page"
android:id="@+id/tv1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="37dp"
android:textColor="#116a1a"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="UserID:"
android:id="@+id/tv2"
android:layout_below="@+id/tv1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="55dp" />
<TextView
android:layout_width="wrap_content"
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Pass:"
android:id="@+id/tv3"
android:layout_below="@+id/tv2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="43dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/et1"
android:ems="10"
android:hint="Enter User id"
android:layout_alignBottom="@+id/tv2"
android:layout_alignLeft="@+id/tv1"
android:layout_alignStart="@+id/tv1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:hint="Enter Password"
android:numeric="integer"
android:id="@+id/et2"
android:layout_alignBottom="@+id/tv3"
android:layout_alignLeft="@+id/et1"
android:layout_alignStart="@+id/et1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:id="@+id/btn"
android:layout_below="@+id/et2"
android:layout_centerHorizontal="true"
android:layout_marginTop="37dp"
android:background="@android:color/darker_gray" />
</RelativeLayout>
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
login.java
package com.example.raj.loginpage;
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 login extends AppCompatActivity {
EditText et1,et2;
Button btn1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
et1 = (EditText)findViewById(R.id.et1);
et2 = (EditText)findViewById(R.id.et2);
btn1 = (Button)findViewById(R.id.btn);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String id = et1.getText().toString();
String pass = et2.getText().toString();
if(id.equals("abc")&& pass.equals("123"))
{
Toast.makeText(getApplicationContext(),"You have Login
Successfully",Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(),"Invalid ID and
Password",Toast.LENGTH_LONG).show();
}
}
});
}
}
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
OUTPUT:
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
PRACTICAL-7
Create an Android App which has one activity to get Fern hit or Celsius. On Pressing
“Convert” button it shows the Result will be displayed on Text View of Activity.
Activity_fernhit.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.raj.fernhit.Fernhit">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/et1"
android:ems="15"
android:hint="Enter Value"
android:layout_marginTop="52dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/tvResult"
android:text="Result"
android:layout_below="@+id/et1"
android:layout_alignLeft="@+id/et1"
android:layout_alignStart="@+id/et1" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Celcius"
android:id="@+id/cb"
android:layout_below="@+id/tvResult"
android:layout_alignLeft="@+id/tvResult"
android:layout_alignStart="@+id/tvResult"
android:layout_marginTop="45dp"
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
android:checked="false" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fahrenhit"
android:id="@+id/fb"
android:checked="false"
android:layout_below="@+id/cb"
android:layout_alignLeft="@+id/cb"
android:layout_alignStart="@+id/cb" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Convert"
android:id="@+id/btn1"
android:onClick="submit"
android:layout_below="@+id/fb"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Fernhit.java
package com.example.raj.fernhit;
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.RadioButton;
import android.widget.TextView;
public class Fernhit extends AppCompatActivity {
EditText et1;
TextView tv1Result;
RadioButton cb,fb;
Button btn1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fernhit);
}
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
public void submit(View v)
{
et1 = (EditText)findViewById(R.id.et1);
tv1Result = (TextView)findViewById(R.id.tvResult);
double a = Double.parseDouble(String.valueOf(et1.getText()));
cb = (RadioButton)findViewById(R.id.cb);
fb = (RadioButton)findViewById(R.id.fb);
if(cb.isChecked())
{
tv1Result.setText(f2c(a)+"Degree C");
fb.setChecked(false);
}
else
{
tv1Result.setText(c2f(a)+"Degree F");
cb.setChecked(false);
}
}
private double c2f(double c)
{
return (c*9)/5+32;
}
private double f2c(double f)
{
return (f-32)*5/9;
}
}
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
OUTPUT:
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
PRACTICAL-8
Create application for demonstrate of second activity using intent.
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.raj.myapplication.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Show First Activity"
android:id="@+id/tv1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Second Activity"
android:id="@+id/btn1"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:onClick="Show"/>
</RelativeLayout>
MainActivity.java
package com.example.raj.myapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void Show(View v)
{
Intent i = new Intent(this,Main2Activity.class);
startActivity(i);
}
}
Activity_main2.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.raj.myapplication.Main2Activity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Show Second Activity"
android:id="@+id/tv1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Main2Activity.java
package com.example.raj.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class Main2Activity extends AppCompatActivity {
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}
}
OUTPUT:
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
PRACTICAL-9
Create application for demonstrate of data passing between First activity to second activity
using intent.
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.raj.myapplication.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Show First Activity"
android:id="@+id/tv1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/et1"
android:hint="Enter Message"
android:layout_below="@+id/tv1"
android:layout_marginTop="64dp"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Second Activity"
android:id="@+id/btn1n"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:onClick="Show"/>
</RelativeLayout>
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
MainActivity.java
package com.example.raj.myapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
EditText et1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void Show(View v)
{
et1 = (EditText)findViewById(R.id.et1);
String text = et1.getText().toString();
Intent i = new Intent(this, Main2Activity.class);
i.putExtra("text",text);
startActivity(i);
}
}
Activity_main2.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.raj.myapplication.Main2Activity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Show Second Activity"
android:id="@+id/tv1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/tv2"
android:layout_below="@+id/tv1"
android:layout_alignLeft="@+id/tv1"
android:layout_marginTop="77dp" />
</RelativeLayout>
Main2Activity.java
package com.example.raj.myapplication;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class Main2Activity extends ActionBarActivity {
TextView tv2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Intent i = getIntent();
String text = i.getStringExtra("text");
tv2 = (TextView)findViewById(R.id.tv2);
tv2.setText(text);
}
}
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
OUTPUT:
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
PRACTICAL-10
Create application for demonstrate of call Built-in application for (ACTION_VIEW &
ACTION_DIAL) activity using intent.
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.raj.google.Google">
<ImageButton
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/imageButton"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@mipmap/ic_launcher_google1"
android:onClick="Google"/>
<ImageButton
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/imageButton2"
android:layout_alignTop="@+id/imageButton"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="@mipmap/ic_launcher_dial"
android:onClick="Dial"/>
</RelativeLayout>
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
MainActivity.java
package com.example.raj.google;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class Google extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_google);
}
public void Google(View v)
{
Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com"));
startActivity(i);
}
public void Dial(View v)
{
Intent i = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:+91"));
startActivity(i);
}
}
ANDROID APPLICATION
DEPARTMET OF COMPUTER ENGINEERING
OUTPUT:

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Fafadia Tech
 
Informatics Practices/ Information Practices Project (IP Project Class 12)
Informatics Practices/ Information Practices Project (IP Project Class 12)Informatics Practices/ Information Practices Project (IP Project Class 12)
Informatics Practices/ Information Practices Project (IP Project Class 12)KushShah65
 
Your Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsYour Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsVu Tran Lam
 
The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212Mahmoud Samir Fayed
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon Berlin
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developersPavel Lahoda
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!Sébastien Levert
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingDevnology
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projectsIgnacio Martín
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services RockPeter Friese
 
De CRUD à DDD pas à pas
De CRUD à DDD pas à pasDe CRUD à DDD pas à pas
De CRUD à DDD pas à pasCharles Desneuf
 

Was ist angesagt? (20)

Property-based testing
Property-based testingProperty-based testing
Property-based testing
 
Nativescript angular
Nativescript angularNativescript angular
Nativescript angular
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
 
Typescript barcelona
Typescript barcelonaTypescript barcelona
Typescript barcelona
 
Informatics Practices/ Information Practices Project (IP Project Class 12)
Informatics Practices/ Information Practices Project (IP Project Class 12)Informatics Practices/ Information Practices Project (IP Project Class 12)
Informatics Practices/ Information Practices Project (IP Project Class 12)
 
Your Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsYour Second iPhone App - Code Listings
Your Second iPhone App - Code Listings
 
The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212
 
Firebase ng2 zurich
Firebase ng2 zurichFirebase ng2 zurich
Firebase ng2 zurich
 
Backbone Basics with Examples
Backbone Basics with ExamplesBackbone Basics with Examples
Backbone Basics with Examples
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahoda
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developers
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
mobl
moblmobl
mobl
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkeling
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services Rock
 
Rxjs vienna
Rxjs viennaRxjs vienna
Rxjs vienna
 
De CRUD à DDD pas à pas
De CRUD à DDD pas à pasDe CRUD à DDD pas à pas
De CRUD à DDD pas à pas
 
Angular mix chrisnoring
Angular mix chrisnoringAngular mix chrisnoring
Angular mix chrisnoring
 

Ähnlich wie Practical

code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql JOYITAKUNDU1
 
Android Location-based應用開發分享
Android Location-based應用開發分享Android Location-based應用開發分享
Android Location-based應用開發分享koji lin
 
안드로이드 세미나 2
안드로이드 세미나 2안드로이드 세미나 2
안드로이드 세미나 2Chul Ju Hong
 
안드로이드 세미나 2
안드로이드 세미나 2안드로이드 세미나 2
안드로이드 세미나 2ang0123dev
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Codemotion
 
Average- An android project
Average- An android projectAverage- An android project
Average- An android projectIpsit Dash
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word documentnidhileena
 
Rohit android lab projects in suresh gyan vihar
Rohit android lab projects in suresh gyan viharRohit android lab projects in suresh gyan vihar
Rohit android lab projects in suresh gyan viharRohit malav
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android WearPeter Friese
 
Android Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and IntentAndroid Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and Intentadmin220812
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your appVitali Pekelis
 
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfJAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfcalderoncasto9163
 

Ähnlich wie Practical (20)

Day 5
Day 5Day 5
Day 5
 
Android App Dev Manual-1.doc
Android App Dev Manual-1.docAndroid App Dev Manual-1.doc
Android App Dev Manual-1.doc
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
20 Codigos
20 Codigos20 Codigos
20 Codigos
 
Android Location-based應用開發分享
Android Location-based應用開發分享Android Location-based應用開發分享
Android Location-based應用開發分享
 
To-Do App With Flutter: Step By Step Guide
To-Do App With Flutter: Step By Step GuideTo-Do App With Flutter: Step By Step Guide
To-Do App With Flutter: Step By Step Guide
 
New text document
New text documentNew text document
New text document
 
안드로이드 세미나 2
안드로이드 세미나 2안드로이드 세미나 2
안드로이드 세미나 2
 
안드로이드 세미나 2
안드로이드 세미나 2안드로이드 세미나 2
안드로이드 세미나 2
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
 
Average- An android project
Average- An android projectAverage- An android project
Average- An android project
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
Rohit android lab projects in suresh gyan vihar
Rohit android lab projects in suresh gyan viharRohit android lab projects in suresh gyan vihar
Rohit android lab projects in suresh gyan vihar
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Exercises
ExercisesExercises
Exercises
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
Android wear (coding)
Android wear (coding)Android wear (coding)
Android wear (coding)
 
Android Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and IntentAndroid Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and Intent
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your app
 
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfJAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
 

Kürzlich hochgeladen

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Kürzlich hochgeladen (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 

Practical

  • 1. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING PRACTICAL-2 A. Create “hello world” application. That will display “Hello World” in the middle of the screen in the black color with wheat color or white background. B. create hello world using java HelloMainActivity.java package com.example.raj.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } Activity_hello_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:background="#fafad2" tools:context="com.example.raj.myapplication.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Hello World" android:textSize="30sp" android:textColor="#B22222" android:layout_centerVertical="true" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
  • 2. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING android:layout_marginTop="99dp" /> </RelativeLayout> Output: B. Create hello world using java package com.example.raj.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView text = new TextView(this); text.setText("Hello World"); setContentView(text); } }
  • 3. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING Output:
  • 4. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING PRACTICAL-3 Create an Android App Which Has one Activity to get two numbers N1 and N2.on pressing Button has four operation Add, Multiply, Divide, Subtract ,on select any one operation it will Display Result in Text View of Activity Activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:background="#fafad2" tools:context="com.example.raj.myapplication.MainActivity" android:weightSum="1"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="No 1:" android:id="@+id/tv1" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/etno1" android:ems="10" android:hint="Enter No1" android:inputType="number"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="No 2:" android:id="@+id/tv2" />
  • 5. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/etno2" android:ems="10" android:hint="Enter No2" android:inputType="number"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Result is" android:id="@+id/tv3" android:layout_gravity="center" /> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> <Button android:layout_width="70dp" android:layout_height="wrap_content" android:text="+" android:id="@+id/Add" /> <Button android:layout_width="70dp" android:layout_height="wrap_content" android:text="-" android:id="@+id/Sub" /> <Button android:layout_width="70dp" android:layout_height="wrap_content" android:text="*" android:id="@+id/Mul" /> <Button android:layout_width="70dp" android:layout_height="wrap_content" android:text="/" android:id="@+id/Div" /> </LinearLayout>
  • 6. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING </LinearLayout> </LinearLayout> MainActivity.java package com.example.raj.myapplication; 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.TextView; public class MainActivity extends AppCompatActivity { TextView tv1, tv2, Result; EditText et1, et2; Button Add, Sub, Mul, Div; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); et1 = (EditText)findViewById(R.id.etno1); et2 = (EditText)findViewById(R.id.etno2); Result = (TextView)findViewById(R.id.tv3); Add = (Button)findViewById(R.id.Add); Sub = (Button)findViewById(R.id.Sub); Mul = (Button)findViewById(R.id.Mul); Div = (Button)findViewById(R.id.Div); Add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TODO Auto-Generated Method... if(et1.getText().toString().equals("")) { et1.setError("Please fill the No1"); } else if(et2.getText().toString().equals("")) { et2.setError("Please fill the No2"); } else {
  • 7. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING int a = Integer.parseInt(et1.getText().toString()); int b = Integer.parseInt(et2.getText().toString()); int c = a + b; Result.setText("Answer="+c); } } }); Sub.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TODO Auto-Generated Method... if(et1.getText().toString().equals("")) { et1.setError("Please fill the No1"); } else if(et2.getText().toString().equals("")) { et2.setError("Please fill the No2"); } else { int a = Integer.parseInt(et1.getText().toString()); int b = Integer.parseInt(et2.getText().toString()); int c = a - b; Result.setText("Answer="+c); } } }); Mul.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TODO Auto-Generated Method... if(et1.getText().toString().equals("")) { et1.setError("Please fill the No1"); } else if(et2.getText().toString().equals("")) { et2.setError("Please fill the No2"); } else { int a = Integer.parseInt(et1.getText().toString());
  • 8. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING int b = Integer.parseInt(et2.getText().toString()); int c = a * b; Result.setText("Answer="+c); } } }); Div.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TODO Auto-Generated Method... if(et1.getText().toString().equals("")) { et1.setError("Please fill the No1"); } else if(et2.getText().toString().equals("")) { et2.setError("Please fill the No2"); } else { int a = Integer.parseInt(et1.getText().toString()); int b = Integer.parseInt(et2.getText().toString()); int c = a / b; Result.setText("Answer="+c); } } }); } }
  • 9. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING OUTPUT:
  • 10. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING PRACTICAL-4 Create application for demonstration of android activity life cycle. Activity_life_cycle.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.raj.lifecycle.LifeCycle"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Android Activity Life Cycle" android:id="@+id/tv1" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /> </RelativeLayout> LifeCycle.java package com.example.raj.lifecycle; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class LifeCycle extends AppCompatActivity { TextView tv1; String text; @Override
  • 11. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_life_cycle); tv1 = (TextView)findViewById(R.id.tv1); text = tv1.getText().toString(); text = text + "n InsideCreate Method"; tv1.setText(text); } public void onStart() { super.onStart(); text = tv1.getText().toString(); text = text + "n InsideStart Method"; tv1.setText(text); } public void onRestart() { super.onRestart(); text = tv1.getText().toString(); text = text + "n InsideRestart Method"; tv1.setText(text); } public void onResume() { super.onResume(); text = tv1.getText().toString(); text = text + "n InsideResume Method"; tv1.setText(text); } public void onPause() { super.onPause(); text = tv1.getText().toString(); text = text + "n InsidePause Method"; tv1.setText(text);
  • 12. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING } public void onStop() { super.onStop(); text = tv1.getText().toString(); text = text + "n InsideStop Method"; tv1.setText(text); } public void onDestroy() { super.onDestroy(); text = tv1.getText().toString(); text = text + "n InsideDestroy Method"; tv1.setText(text); } } OUTPUT:
  • 13. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING PRACTICAL-5 Create Registration page to demonstration of Basic widgets available in android. Activity_widgetdemo.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.raj.widgetdemo.widgetdemo"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Registration" android:id="@+id/tv1" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Name:" android:id="@+id/tv2" android:layout_below="@+id/tv1" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="37dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Mobile No:" android:id="@+id/tv3" android:layout_below="@+id/tv2" android:layout_alignParentLeft="true" android:layout_alignParentStart="true"
  • 14. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING android:layout_marginTop="39dp" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/et1" android:layout_above="@+id/tv3" android:layout_alignLeft="@+id/tv1" android:layout_alignStart="@+id/tv1" android:ems="10" android:hint="name"/> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/et2" android:layout_alignTop="@+id/tv3" android:layout_alignLeft="@+id/et1" android:layout_alignStart="@+id/et1" android:ems="10" android:hint="mobile no"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Cast:" android:id="@+id/tv4" android:layout_centerVertical="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> <RadioGroup android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/et2" android:layout_alignLeft="@+id/et2" android:layout_alignStart="@+id/et2" android:id="@+id/radioGroup"> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="General" android:id="@+id/rb1" android:checked="false" />
  • 15. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="SEBC" android:id="@+id/rb2" android:checked="false" /> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="SC" android:id="@+id/rb3" android:checked="false" /> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ST" android:id="@+id/rb4" android:checked="false" /> </RadioGroup> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Language:" android:id="@+id/tv5" android:layout_below="@+id/radioGroup" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="37dp" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Gujarati" android:id="@+id/chk1" android:checked="false" android:layout_alignBottom="@+id/tv5" android:layout_alignLeft="@+id/btn" android:layout_alignStart="@+id/btn" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hindi"
  • 16. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING android:id="@+id/chk2" android:checked="false" android:layout_alignTop="@+id/chk1" android:layout_toRightOf="@+id/tv1" android:layout_toEndOf="@+id/tv1" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="SUBMIT" android:id="@+id/btn" android:layout_alignLeft="@+id/radioGroup" android:layout_alignStart="@+id/radioGroup" android:layout_below="@+id/chk1" android:onClick="submit"/> </RelativeLayout> widgetdemo.java package com.example.raj.widgetdemo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Toast; public class widgetdemo extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_widgetdemo); } public void submit(View v) { Toast.makeText(this,"You have Registered successfully.",Toast.LENGTH_LONG).show(); } }
  • 17. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING OUTPUT:
  • 18. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING PRACTICAL-6 Create sample application with login module. (Check username and password) on successful login, change Text view “Login Successful.” And on failing login, alert user using Toast “Login fail.” Activity_login.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.example.raj.loginpage.login" android:background="#f0dfc9"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Login Page" android:id="@+id/tv1" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="37dp" android:textColor="#116a1a" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="UserID:" android:id="@+id/tv2" android:layout_below="@+id/tv1" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="55dp" /> <TextView android:layout_width="wrap_content"
  • 19. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Pass:" android:id="@+id/tv3" android:layout_below="@+id/tv2" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="43dp" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/et1" android:ems="10" android:hint="Enter User id" android:layout_alignBottom="@+id/tv2" android:layout_alignLeft="@+id/tv1" android:layout_alignStart="@+id/tv1" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textPassword" android:ems="10" android:hint="Enter Password" android:numeric="integer" android:id="@+id/et2" android:layout_alignBottom="@+id/tv3" android:layout_alignLeft="@+id/et1" android:layout_alignStart="@+id/et1" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login" android:id="@+id/btn" android:layout_below="@+id/et2" android:layout_centerHorizontal="true" android:layout_marginTop="37dp" android:background="@android:color/darker_gray" /> </RelativeLayout>
  • 20. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING login.java package com.example.raj.loginpage; 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 login extends AppCompatActivity { EditText et1,et2; Button btn1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); et1 = (EditText)findViewById(R.id.et1); et2 = (EditText)findViewById(R.id.et2); btn1 = (Button)findViewById(R.id.btn); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String id = et1.getText().toString(); String pass = et2.getText().toString(); if(id.equals("abc")&& pass.equals("123")) { Toast.makeText(getApplicationContext(),"You have Login Successfully",Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplicationContext(),"Invalid ID and Password",Toast.LENGTH_LONG).show(); } } }); } }
  • 21. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING OUTPUT:
  • 22. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING PRACTICAL-7 Create an Android App which has one activity to get Fern hit or Celsius. On Pressing “Convert” button it shows the Result will be displayed on Text View of Activity. Activity_fernhit.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.raj.fernhit.Fernhit"> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/et1" android:ems="15" android:hint="Enter Value" android:layout_marginTop="52dp" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/tvResult" android:text="Result" android:layout_below="@+id/et1" android:layout_alignLeft="@+id/et1" android:layout_alignStart="@+id/et1" /> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Celcius" android:id="@+id/cb" android:layout_below="@+id/tvResult" android:layout_alignLeft="@+id/tvResult" android:layout_alignStart="@+id/tvResult" android:layout_marginTop="45dp"
  • 23. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING android:checked="false" /> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Fahrenhit" android:id="@+id/fb" android:checked="false" android:layout_below="@+id/cb" android:layout_alignLeft="@+id/cb" android:layout_alignStart="@+id/cb" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Convert" android:id="@+id/btn1" android:onClick="submit" android:layout_below="@+id/fb" android:layout_centerHorizontal="true" /> </RelativeLayout> Fernhit.java package com.example.raj.fernhit; 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.RadioButton; import android.widget.TextView; public class Fernhit extends AppCompatActivity { EditText et1; TextView tv1Result; RadioButton cb,fb; Button btn1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fernhit); }
  • 24. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING public void submit(View v) { et1 = (EditText)findViewById(R.id.et1); tv1Result = (TextView)findViewById(R.id.tvResult); double a = Double.parseDouble(String.valueOf(et1.getText())); cb = (RadioButton)findViewById(R.id.cb); fb = (RadioButton)findViewById(R.id.fb); if(cb.isChecked()) { tv1Result.setText(f2c(a)+"Degree C"); fb.setChecked(false); } else { tv1Result.setText(c2f(a)+"Degree F"); cb.setChecked(false); } } private double c2f(double c) { return (c*9)/5+32; } private double f2c(double f) { return (f-32)*5/9; } }
  • 25. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING OUTPUT:
  • 26. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING PRACTICAL-8 Create application for demonstrate of second activity using intent. Activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.raj.myapplication.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Show First Activity" android:id="@+id/tv1" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Show Second Activity" android:id="@+id/btn1" android:layout_centerVertical="true" android:layout_centerHorizontal="true" android:onClick="Show"/> </RelativeLayout> MainActivity.java package com.example.raj.myapplication; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompatActivity {
  • 27. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void Show(View v) { Intent i = new Intent(this,Main2Activity.class); startActivity(i); } } Activity_main2.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.raj.myapplication.Main2Activity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Show Second Activity" android:id="@+id/tv1" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /> </RelativeLayout> Main2Activity.java package com.example.raj.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class Main2Activity extends AppCompatActivity {
  • 28. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); } } OUTPUT:
  • 29. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING PRACTICAL-9 Create application for demonstrate of data passing between First activity to second activity using intent. Activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.raj.myapplication.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Show First Activity" android:id="@+id/tv1" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/et1" android:hint="Enter Message" android:layout_below="@+id/tv1" android:layout_marginTop="64dp" android:layout_alignParentRight="true" android:layout_alignParentLeft="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Show Second Activity" android:id="@+id/btn1n" android:layout_centerVertical="true" android:layout_centerHorizontal="true" android:onClick="Show"/> </RelativeLayout>
  • 30. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING MainActivity.java package com.example.raj.myapplication; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.EditText; public class MainActivity extends AppCompatActivity { EditText et1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void Show(View v) { et1 = (EditText)findViewById(R.id.et1); String text = et1.getText().toString(); Intent i = new Intent(this, Main2Activity.class); i.putExtra("text",text); startActivity(i); } } Activity_main2.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.raj.myapplication.Main2Activity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Show Second Activity" android:id="@+id/tv1" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" />
  • 31. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/tv2" android:layout_below="@+id/tv1" android:layout_alignLeft="@+id/tv1" android:layout_marginTop="77dp" /> </RelativeLayout> Main2Activity.java package com.example.raj.myapplication; import android.content.Intent; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView; public class Main2Activity extends ActionBarActivity { TextView tv2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); Intent i = getIntent(); String text = i.getStringExtra("text"); tv2 = (TextView)findViewById(R.id.tv2); tv2.setText(text); } }
  • 32. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING OUTPUT:
  • 33. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING PRACTICAL-10 Create application for demonstrate of call Built-in application for (ACTION_VIEW & ACTION_DIAL) activity using intent. Activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.raj.google.Google"> <ImageButton android:layout_width="100dp" android:layout_height="100dp" android:id="@+id/imageButton" android:layout_centerVertical="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:background="@mipmap/ic_launcher_google1" android:onClick="Google"/> <ImageButton android:layout_width="100dp" android:layout_height="100dp" android:id="@+id/imageButton2" android:layout_alignTop="@+id/imageButton" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:background="@mipmap/ic_launcher_dial" android:onClick="Dial"/> </RelativeLayout>
  • 34. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING MainActivity.java package com.example.raj.google; import android.content.Intent; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; public class Google extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_google); } public void Google(View v) { Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com")); startActivity(i); } public void Dial(View v) { Intent i = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:+91")); startActivity(i); } }
  • 35. ANDROID APPLICATION DEPARTMET OF COMPUTER ENGINEERING OUTPUT: