package com.example.activitylifecycle;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
((TextView)findViewById(R.id.textViewState)).setText("onCreate()\n");
}
@Override
protected void onStart() {
super.onStart();
((TextView) findViewById(R.id.textViewState)).append("onStart()\n");
}
@Override
protected void onResume() {
super.onResume();
((TextView) findViewById(R.id.textViewState)).append("onResume()\n");
}
@Override
public void onPause() {
super.onPause();
((TextView) findViewById(R.id.textViewState)).append("onPause()\n");
if (isFinishing()) {
((TextView) findViewById(R.id.textViewState)).append(" ... finishing");
}
}
@Override
protected void onStop() {
super.onStop();
((TextView) findViewById(R.id.textViewState)).append("onStop()\n");
}
@Override
protected void onRestart() {
super.onRestart();
((TextView) findViewById(R.id.textViewState)).append("onRestart()\n");
}
@Override
protected void onDestroy() {
super.onDestroy();
((TextView) findViewById(R.id.textViewState)).append("onDestroy()\n");
}
}
Search thousands of free JavaScript snippets that you can quickly copy and paste into your web pages. Get free JavaScript tutorials, references, code, menus, calendars, popup windows, games, and much more.
【Android Studio】 Activity Lifecycle
Subscribe to:
Post Comments (Atom)
This will make you a better decision maker | Annie Duke (author of “Thinking in Bets” and “Quit”, former pro poker…
Annie is a former professional poker player, decision-making expert, author, and special partner at First Round Capital. ͏ ͏ ͏ ...
No comments:
Post a Comment