@Override
 public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
   mCursor.moveToPosition(position);
   String packagename = mCursor.getString(mCursor.getColumnIndex(AppData.App.PKG_NAME));
   Intent intent = pm.getLaunchIntentForPackage(packagename);
   if (null == intent) {
     mNotice.showToast(R.string.cannot_start_app);
     return;
   }
   startActivity(intent);
 }
  @Override
  public void onReceiveFile(FileReceiver fileReceiver) {
    String fileName = fileReceiver.getFileTransferInfo().getFileName();
    String sendUserName = fileReceiver.getSendUser().getUserName();
    File file = null;
    long fileSize = fileReceiver.getFileTransferInfo().getFileSize();
    Log.d(TAG, "onReceiveFile:" + fileName + "," + sendUserName + ",size=" + fileSize);
    // define a file to save the receive file
    File fileDir = new File(DreamConstant.DREAMLINK_FOLDER);
    if (!fileDir.exists()) {
      fileDir.mkdirs();
    }

    String filePath = DreamConstant.DREAMLINK_FOLDER + File.separator + fileName;
    file = new File(filePath);
    if (!file.exists()) {
      try {
        file.createNewFile();
      } catch (IOException e) {
        Log.e(TAG, "create file error:" + e.toString());
        mNotice.showToast("can not create the file:" + fileName);
        return;
      }
    } else {
      // if file is exist,auto rename
      fileName = FileInfoManager.autoRename(fileName);
      while (new File(DreamConstant.DREAMLINK_FOLDER + File.separator + fileName).exists()) {
        fileName = FileInfoManager.autoRename(fileName);
      }
      filePath = DreamConstant.DREAMLINK_FOLDER + File.separator + fileName;
      file = new File(filePath);
    }

    HistoryInfo historyInfo = new HistoryInfo();
    historyInfo.setFile(file);
    historyInfo.setFileSize(fileSize);
    historyInfo.setSendUserName(sendUserName);
    historyInfo.setReceiveUser(mUserManager.getLocalUser());
    historyInfo.setMsgType(HistoryManager.TYPE_RECEIVE);
    historyInfo.setDate(System.currentTimeMillis());
    historyInfo.setStatus(HistoryManager.STATUS_PRE_RECEIVE);
    historyInfo = mFileInfoManager.getHistoryInfo(historyInfo);

    ContentValues values = mHistoryManager.getInsertValues(historyInfo);
    Uri uri = getContentResolver().insert(MetaData.History.CONTENT_URI, values);
    Object key = new Object();
    mTransferMap.put(key, uri);
    Log.d(TAG, "onReceiveFile.mTransferMap.size=" + mTransferMap.size());

    fileReceiver.receiveFile(file, FileTransferService.this, key);
  }