コード例 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Util.setPrefTheme(this);
    super.onCreate(savedInstanceState);
    Log.i(LOG_TAG, "initiating adapter");
    mAdapter = new DatabaseAdapter(this);
    mAdapter.open();

    Bundle b = this.getIntent().getExtras();
    if (b != null) {
      mNoteId = b.getLong(DatabaseAdapter.ID_COL, Const.INVALID_LONG);
      Log.i(LOG_TAG, "Got note ID from intent's bundle: " + mNoteId);
    }
    if (mNoteId == Const.INVALID_LONG) {
      Serializable savedState = savedInstanceState.getSerializable(DatabaseAdapter.ID_COL);
      mNoteId =
          savedState == null || !(savedState instanceof Long)
              ? Const.INVALID_LONG
              : (Long) savedState;
      Log.i(LOG_TAG, "Nothing in the intent, and mNoteId in saved instance state is: " + mNoteId);
    }
    this.setContentView(R.layout.view_note);
    // note display is in onResume
    this.displayNoteOrGoUp();
  }