@Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case MENU_ID_UPGRADE:
        if (Util.isLowBattery(getApplicationContext())) {
          showDialog(DIALOG_LOW_BATTERY);
        } else {
          showDialog(DIALOG_INSTALLWARNING);
        }
        return true;
      case android.R.id.home:
        Xlog.v(TAG, "Navigation key,finish activity");
        if (!mDownloadInfo.getIfNeedRefreshMenu()) {

          if (mDownloadInfo.getActivityID() < 0) {
            mGoToMainEntry = true;
            SdPkgInstallActivity.this.startActivity(new Intent(this, MainEntry.class));
          }
        }
        SdPkgInstallActivity.this.finish();
        break;
      case MENU_ID_REFRESH:
        mGoToMainEntry = true;
        requeryPackages();
        break;
      default:
        break;
    }
    return super.onOptionsItemSelected(item);
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    if (mDownloadInfo.getIfNeedRefreshMenu() && mDownloadInfo.getActivityID() < 0) {
      menu.add(0, MENU_ID_REFRESH, 0, R.string.menu_stats_refresh)
          .setIcon(R.drawable.ic_menu_refresh_holo_dark)
          .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    return super.onCreateOptionsMenu(menu);
  }
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    Xlog.w(TAG, "event.getFlages()" + event.getFlags());
    switch (keyCode) {
      case KeyEvent.KEYCODE_BACK:
        Xlog.w(TAG, "onKeyDown, keycode is KEYCODE_BACK");
        if (!mDownloadInfo.getIfNeedRefreshMenu()) {

          if (mDownloadInfo.getActivityID() < 0) {
            mGoToMainEntry = true;
            SdPkgInstallActivity.this.startActivity(new Intent(this, MainEntry.class));
          }
        }
        break;
      default:
        break;
    }
    return super.onKeyDown(keyCode, event);
  }