Write a program to implement Android Activity Life Cycle. Use toast messages to display message through life cycle.
![](https://www.blogger.com/img/transparent.gif)
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
oast.makeText(getApplicationContext()
,"Activity
created",Toast.LENGTH_LONG).show();
}
@Override
protected void onStart()
{
super.onStart();
Toast.makeText(getApplicationContext(),
"Activity
Started",Toast.LENGTH_LONG).show();
}
@Override
protected void onStop()
{
super.onStop();
Toast.makeText(getApplicationContext(),
"Activity
Stop",Toast.LENGTH_LONG).show();
}
@Override
protected void onDestroy()
{
super.onDestroy();
Toast.makeText(getApplicationContext(),
"Activity
Destroy",Toast.LENGTH_LONG)
.show();
}
@Override
protected void onPause()
{
super.onPause();
Toast.makeText(getApplicationContext()
,"Activity
Pause",Toast.LENGTH_LONG)
.show();
}
@Override
protected void onRestart()
{
super.onResume();
Toast.makeText(getApplicationContext(),
"Activity
Restart",Toast.LENGTH_LONG).show();
@Override
protected void onResume()
{
super.onResume();
Toast.makeText(getApplicationContext()
"Activity
Resume",Toast.LENGTH_LONG).show();
}
}
@Override
protected void onPause()
{
super.onPause();
Toast.makeText(getApplicationContext()
,"Activity
Pause",
Toast.LENGTH_LONG)
.show();
}
@Override
protected void onRestart()
{
super.onResume();
Toast.makeText(getApplicationContext()
,"Activity
Restart",Toast.LENGTH_LONG).show();
@Override
protected void onResume()
{
super.onResume();
Toast.makeText(getApplicationContext(),
"Activity
Resume",Toast.LENGTH_LONG).show();
}
}
0 Comments