0% found this document useful (0 votes)
35 views3 pages

Practical No - 17

practical no 17 mad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

Practical No - 17

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

“Program To Create An Activity”

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_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java
public class MainActivity extends AppCompatActivity {
String msg = "Android";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(msg, "onCreate Invoked");
Toast.makeText(MainActivity.this, "onCreate Invoked", Toast.LENGTH_SHORT).show();
}

@Override
protected void onStart() {
super.onStart();
Log.d(msg, "onStart Invoked");
Toast.makeText(MainActivity.this, "onStart Invoked", Toast.LENGTH_SHORT).show();
}

@Override
protected void onResume() {
super.onResume();
Log.d(msg, "onResume Invoked");
Toast.makeText(MainActivity.this, "onResume Invoked", Toast.LENGTH_SHORT).show();
}

@Override
protected void onPause() {
super.onPause();
Log.d(msg, "onPause Invoked");
Toast.makeText(MainActivity.this, "onPause Invoked", Toast.LENGTH_SHORT).show();
}

@Override
protected void onStop() {
super.onStop();
Log.d(msg, "onStop Invoked");
Toast.makeText(MainActivity.this, "onStop Invoked", Toast.LENGTH_SHORT).show();
}

@Override
protected void onRestart() {
super.onRestart();
Log.d(msg, "onRestart Invoked");
Toast.makeText(MainActivity.this, "onRestart Invoked", Toast.LENGTH_SHORT).show();
}

@Override
protected void onDestroy() {
super.onDestroy();
Log.d(msg, "onDestroy Invoked");
Toast.makeText(MainActivity.this, "onDestroy Invoked", Toast.LENGTH_SHORT).show();
}

You might also like