AndroidManifest.xml:
MainActivity.java:
activity_main.xml:
Output:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.blogspot.codingatharva.manualprograms"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
MainActivity.java:
package com.blogspot.codingatharva.manualprograms;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("Activity:", "Created");
}
@Override
protected void onStart() {
super.onStart();
Log.d("Activity:", "Started");
}
@Override
protected void onResume() {
super.onResume();
Log.d("Activity:", "Resume");
}
@Override
protected void onPause() {
super.onPause();
Log.d("Activity:", "Pause");
}
@Override
protected void onStop() {
super.onStop();
Log.d("Activity:", "Stop");
}
@Override
protected void onRestart() {
super.onRestart();
Log.d("Activity:", "Restart");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.d("Activity:", "Destroy");
}
}
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:paddingTop="80dp" tools:context=".MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World"/> </RelativeLayout>
Output:
