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

Practical No 17

The document outlines the structure of an Android application, including the AndroidManifest.xml, activity_main.xml, and MainActivity.java files. It defines the main activity with a 'Hello, World!' text view and includes lifecycle logging methods in the MainActivity class. The application is set up to support backup and has a specified theme and icon.

Uploaded by

mr.ompawar9834
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)
3 views4 pages

Practical No 17

The document outlines the structure of an Android application, including the AndroidManifest.xml, activity_main.xml, and MainActivity.java files. It defines the main activity with a 'Hello, World!' text view and includes lifecycle logging methods in the MainActivity class. The application is set up to support backup and has a specified theme and icon.

Uploaded by

mr.ompawar9834
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/ 4

Practical No.

: 17
Name : Om Dadaji Pawar
Roll No : 16

Input :
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Pr17_create_an_activity"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>

</manifest>

activity_main.java
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".MainActivity">

<TextView
android:id="@+id/tvHelloWorld"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, World!"
android:textSize="24sp"
android:textStyle="bold"
android:textColor="@android:color/black"
android:padding="16dp" />
</LinearLayout>

MainActivity.java
package com.example.pr17_create_an_activity;

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

public class MainActivity extends AppCompatActivity {

// Tag for logging


private static final String TAG = "MainActivity";

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

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

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

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

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

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

You might also like