You are on page 1of 6

Mobile Application Development with ANDROID 1620BEIT30032

Practical:-1
AIM:- Create “First Android Application”, that will display “LDRP-ITR” in the
middle of the screen in the Blue color with White background.

activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
android:background="#FFF"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LDRP-ITR"
android:textColor="#003BB8"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java:
package com.example.practical1;

import androidx.appcompat.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);
}
}

LDRP-ITR Page | 1
Mobile Application Development with ANDROID 1620BEIT30032

Output:

LDRP-ITR Page | 2
Mobile Application Development with ANDROID 1620BEIT30032

Practical:-2
AIM:- Android system initiates its program with in an Activity starting with a
call on onCreate() callback method. There is a sequence of callback methods
that start up an activity and a sequence of callback methods that tear down an
activity. Create an app to demonstrate it.

activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java:
package com.example.practical2;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("onCreate","onCreate: ");
}

LDRP-ITR Page | 3
Mobile Application Development with ANDROID 1620BEIT30032

@Override
protected void onStart() {
super.onStart();
Log.d("onStart", "onStart: ");
}

@Override
protected void onPause() {
super.onPause();
Log.d("onPause", "onPause: ");
}

@Override
protected void onResume() {
super.onResume();
Log.d("onResume", "onResume: ");
}

@Override
protected void onRestart() {
super.onRestart();
Log.d( "onRestart", "onRestart: ");
}

@Override
protected void onStop() {
super.onStop();
Log.d( "onStop", "onStop: ");
}

@Override
protected void onDestroy() {
super.onDestroy();
Log.d( "onDestroy", "onDestroy: ");
}
}

LDRP-ITR Page | 4
Mobile Application Development with ANDROID 1620BEIT30032

Output:

LDRP-ITR Page | 5
Mobile Application Development with ANDROID 1620BEIT30032

LDRP-ITR Page | 6

You might also like