@Override
 protected void onResume() {
   Common.log(TAG, "onResume()");
   super.onResume();
   Common.log(TAG, "onResume(): mMessageId = " + mMessageId);
   DatabaseUtils.dumpCursor(mMessage);
 }
  private void startTrack() {
    Common.log(TAG, "startTrack()");
    mDbHelper.setMessageToStarted(mMessageId);

    Intent intent = new Intent(this, LoggerMap.class);
    intent.putExtra(LoggerMap.PARTNER_RUN_KEY, true);
    startActivity(intent);
  }
  private void startMessageSender() {
    Common.log(TAG, "startMessageSender()");

    Intent intent = new Intent(this, MessageSender.class);
    intent.putExtra(Users.TABLE, mReplyRecipientIds);
    if (mMsgObject.mType == GameMessages.TYPE_GENERIC)
      intent.putExtra(GameMessages.SUBJECT, "Re: " + mMsgObject.mSubject);
    startActivity(intent);
  }
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    Log.v(TAG, "position = " + position + "; id = " + id);

    if (position < 3) return;

    int userId = (Integer) mGroupAdapter.getItem(position);
    Common.log(TAG, "onListItemClick(): user id = " + userId);
    Intent i = new Intent(this, PeopleTrackList.class);
    i.putExtra("userId", userId);
    startActivity(i);
  }
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Common.log(TAG, "onCreate()");
    this.setContentView(R.layout.gamemessagedetail);

    mMessageId = savedInstanceState != null ? savedInstanceState.getLong(GameMessages.TABLE) : 0;
    if (mMessageId == 0) {
      Bundle extras = getIntent().getExtras();
      mMessageId = extras != null ? extras.getLong(GameMessages.TABLE) : 0;
    }

    mDbHelper = new DatabaseHelper(this);
    mDbHelper.openAndGetDb();

    mMessage = mDbHelper.getMessageWithId(mMessageId);
    startManagingCursor(mMessage);
    mMessage.moveToFirst();
    mPeople = mDbHelper.getUsersForMessage(mMessageId, mMessage.getLong(1));
    startManagingCursor(mPeople);

    mMsgObject =
        new MessageObject(
            mMessage.getInt(2),
            mMessage.getLong(5),
            mMessage.getLong(4),
            mMessage.getString(6),
            mMessage.getString(7));

    mDidStart = mMessage.getInt(9);

    mPeople.moveToPosition(-1);
    ArrayList<Long> recipients = new ArrayList<Long>(mPeople.getCount());
    while (mPeople.moveToNext())
      if (mPeople.getLong(1) != Common.getRegisteredUser(this).id)
        recipients.add(mPeople.getLong(1));

    mReplyRecipientIds = new long[recipients.size()];
    for (int i = 0; i < mReplyRecipientIds.length; i++) mReplyRecipientIds[i] = recipients.get(i);

    // Common.log(TAG, Arrays.toString(mReplyRecipientIds));

    mPeople.moveToFirst();

    mStartButton = (Button) findViewById(R.id.startbutton);
    mStartButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            startTrack();
          }
        });
    mStartButton.setVisibility(View.GONE);

    mReplyButton = (Button) findViewById(R.id.replybutton);
    mReplyButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            startMessageSender();
          }
        });

    if (!(mPeople.getCount() == 1 && mPeople.getInt(1) == Common.getRegisteredUser(this).id)) {
      if ((mMsgObject.mType == GameMessages.TYPE_INVITE
              || mMsgObject.mType == GameMessages.TYPE_CHALLENGE)
          && mDidStart == 0) mStartButton.setVisibility(View.VISIBLE);
      if (!(mPeople.getCount() > 1)) mReplyButton.setText("Reply");
    }
    setTitle("Message");
    fillData();
  }
 @Override
 protected void onRestart() {
   Common.log(TAG, "onRestart()");
   mDbHelper.openAndGetDb();
   super.onRestart();
 }