Skip to content

Instantly share code, notes, and snippets.

@wowiwo1
Last active September 15, 2015 04:45
Show Gist options
  • Save wowiwo1/a6e2f8706a2a9d73d3d5 to your computer and use it in GitHub Desktop.
Save wowiwo1/a6e2f8706a2a9d73d3d5 to your computer and use it in GitHub Desktop.
public class MainActivity extends Activity {
private static final String TAG = "WDG";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_android_sample01);
Log.d(TAG, "onCreate");
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Log.d(TAG, "onSaveInstanceState");
final EditText et = (EditText) findViewById(R.id.et_welcome);
CharSequence userText = et.getText();
outState.putCharSequence("savedText", userText);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
Log.d(TAG, "onRestoreInstanceState");
final EditText et = (EditText) findViewById(R.id.et_welcome);
CharSequence userText = savedInstanceState.getCharSequence("savedText");
et.setText(userText);
}
@Override
protected void onRestart() {
super.onRestart();
Log.d(TAG, "onRestart");
}
@Override
protected void onStart() {
super.onStart();
Log.d(TAG, "onStart");
}
@Override
protected void onResume() {
super.onResume();
Log.d(TAG, "onResume");
}
@Override
protected void onPause() {
super.onPause();
Log.d(TAG, "onPause");
}
@Override
protected void onStop() {
super.onStop();
Log.d(TAG, "onStop");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.d(TAG, "onDestroy");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_android_sample01, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment