Пример #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    // 如果activity是被用户按下back或者调用finish终止的,那onCreate里面的savedInstanceState变量为null
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ui_test_layout1);

    rootLayout = (LinearLayout) findViewById(R.id.ll_linearlayout_root);

    int count = rootLayout.getChildCount();
    for (int i = 0; i < count; i++) {

      Log.d(TAG, rootLayout.getChildAt(i).toString());
    }

    mTextView = (TextView) findViewById(R.id.textView1);

    if (savedInstanceState == null) {

      createActivitySharedPreference();
    } else {

      if (savedInstanceState.containsKey(TEXTVIEW_STATE_KEY)) {

        mTextView.setText(savedInstanceState.getString(TEXTVIEW_STATE_KEY));
      }
    }
  }
Пример #2
0
  @Override
  public void onTrimMemory(int level) {

    // 接收UI被隐藏的消息,此时需要释放你的UI所占用的资源
    if (level == Activity.TRIM_MEMORY_UI_HIDDEN) {}

    super.onTrimMemory(level);
  }
Пример #3
0
  /**
   * 这个函数是在Activity被RunTimer终止时才会调用的(比如屏幕旋转的时候). 也就是说如果该activity是被用户按下back键或者调用finish函数终止的 ,那
   * onSaveInstanceSate函数是不会被调用的
   */
  @Override
  protected void onSaveInstanceState(Bundle outState) {

    Log.d(TAG, "onSaveInstanceState");

    // 在Shared Preferences中存储新的基本类型
    outState.putString(TEXTVIEW_STATE_KEY, "bbbbbbbbbbbbbbbbbbbbbbbbbbbb");

    super.onSaveInstanceState(outState);
  }
Пример #4
0
 @Override
 protected void onResume() {
   super.onResume();
   Log.d(TAG, "onResume");
 }
Пример #5
0
 @Override
 protected void onStart() {
   super.onStart();
 }
Пример #6
0
 @Override
 protected void onDestroy() {
   Log.d(TAG, "onDestroy");
   super.onDestroy();
 }
Пример #7
0
 @Override
 protected void onStop() {
   Log.d(TAG, "onStop");
   super.onStop();
 }
Пример #8
0
 @Override
 protected void onPause() {
   super.onPause();
   Log.d(TAG, "onPause");
 }