public void loginAndStart() {
   if (choId != 0) {
     logout();
     return;
   }
   EditText editCHO = (EditText) findViewById(R.id.editCHOName);
   if (editCHO.getText().length() == 0) {
     textStatus.setText("enter your user name to open");
     textStatus.setTextColor(this.getResources().getColor(R.color.text_color_error));
     return;
   }
   CHOs chos = new CHOs(getApplicationContext());
   currentCHO = chos.getCHO(editCHO.getText().toString());
   if (currentCHO == null) {
     textStatus.setText("the name you entred is not found");
     textStatus.setTextColor(this.getResources().getColor(R.color.text_color_error));
     return;
   }
   editCHO.setEnabled(false);
   choId = currentCHO.getId();
   buttonOpenClose.setText(R.string.close);
   findViewById(R.id.buttonMainOpenRecord).setEnabled(true);
   findViewById(R.id.buttonMainKnowledge).setEnabled(true);
   findViewById(R.id.buttonHealthPromotions).setEnabled(true);
   // findViewById(R.id.buttonAddCommunity).setEnabled(true);
   textStatus.setText("application open");
   textStatus.setTextColor(this.getResources().getColor(R.color.text_color_black));
   ListView list = (ListView) findViewById(R.id.list);
   Tasks tasks = new Tasks(this);
   list.setAdapter(tasks.getTaskAdapterForTheMonth());
   list.setOnItemClickListener(
       new OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
           openRecordFromTask(position);
         }
       });
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    log = new LogData(getActivity());
    chos = new CHOs(getActivity());
    currentCHO = chos.getCHO(this.choId);
    mContentView = inflater.inflate(R.layout.device_detail, null);
    mContentView
        .findViewById(R.id.btn_connect)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                WifiP2pConfig config = new WifiP2pConfig();
                config.deviceAddress = device.deviceAddress;
                config.wps.setup = WpsInfo.PBC;
                if (progressDialog != null && progressDialog.isShowing()) {
                  progressDialog.dismiss();
                }
                progressDialog =
                    ProgressDialog.show(
                        getActivity(),
                        "Press back to cancel",
                        "Connecting to :" + device.deviceAddress,
                        true,
                        true);
                ((DeviceActionListener) getActivity()).connect(config);
                Date date1 = new Date();
                DateFormat dt = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss", Locale.UK);
                // log.addLog(0501, dt.format(date1), currentCHO.getFullname(),
                //     		    this.getClass().getName() + " Method: onClick()", "Connection
                // initiated. To device: " +  device.deviceAddress );

              }
            });

    mContentView
        .findViewById(R.id.btn_disconnect)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                ((DeviceActionListener) getActivity()).disconnect();
              }
            });

    return mContentView;
  }
 public void setChoId(int choId) {
   Log.d("setting ID", String.valueOf(choId));
   this.choId = choId;
   this.currentCHO = chos.getCHO(this.choId);
 }