@Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.agentslist);

    // get the database
    inContactData = openOrCreateDatabase("inContactData", MODE_PRIVATE, null);

    //
    // set up the quick action popup
    //
    ActionItem chatAgent =
        new ActionItem(
            ID_SMSAGENT, "Text", getResources().getDrawable(R.drawable.ic_action_example));
    ActionItem callAgent =
        new ActionItem(
            ID_CALLAGENT, "Call", getResources().getDrawable(R.drawable.ic_action_phone));
    ActionItem icMessageAgent =
        new ActionItem(
            ID_ICMESSAGEAGENT,
            "iCMessage",
            getResources().getDrawable(R.drawable.ic_action_example));

    mQuickAction = new QuickAction(this);
    mQuickAction.addActionItem(chatAgent);
    mQuickAction.addActionItem(callAgent);
    mQuickAction.addActionItem(icMessageAgent);

    mQuickAction.setOnActionItemClickListener(
        new QuickAction.OnActionItemClickListener() {

          public void onItemClick(QuickAction source, int pos, int actionId) {
            ActionItem actionItem = source.getActionItem(pos);
            switch (actionId) {
              case ID_CALLAGENT:
                {
                  Toast.makeText(getApplicationContext(), "call agent", Toast.LENGTH_SHORT).show();
                  break;
                }

              case ID_SMSAGENT:
                {
                  Toast.makeText(getApplicationContext(), "text agent", Toast.LENGTH_SHORT).show();
                  break;
                }

              case ID_ICMESSAGEAGENT:
                {
                  if (mInSideWSService != null) {
                    DateTime dt = new DateTime();
                    dt = dt.plusDays(5);
                    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
                    String validUntilDate = fmt.print(dt);
                    mInSideWSService.sendAgentMessage(
                        InContactAgentMessageScopes.Agent,
                        new int[] {Integer.parseInt(mSelectedAgentId)},
                        "Hey you",
                        "Useless Things",
                        validUntilDate,
                        5);
                  }
                  break;
                }
            }
          }
        });

    mQuickAction.setOnDismissListener(
        new QuickAction.OnDismissListener() {

          public void onDismiss() {
            Toast.makeText(getApplicationContext(), "Ups..dismissed", Toast.LENGTH_SHORT).show();
          }
        });

    Log.i("sortedagent.oncreate", "creating service object");
    //
    // creating service connection
    //
    mInSideWSConnection =
        new ServiceConnection() {

          //
          // service connected handler
          //
          public void onServiceConnected(ComponentName comp, IBinder binder) {
            InSideWSServiceBinder b = (InSideWSServiceBinder) binder;
            mInSideWSService = b.getService();
            mInSideWSService.registerListener(SortedAgentList.this);
            Log.i("sortedagent.connected", "connected!");
            setAdapter();
          }

          //
          // service disconnected handler
          //
          public void onServiceDisconnected(ComponentName comp) {
            // TODO Auto-generated method stub
            mBound = false;
          }
        };

    refreshAgentsButton = (Button) findViewById(R.id.refreshAgentsButton);
    refreshAgentsButton.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {

            SortedAgentList.this.mInSideWSService.requestActiveAgentsRefresh();
          }
        });

    testButton = (Button) findViewById(R.id.button1);
    testButton.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(), AgentViewActivity.class));
          }
        });

    //
    // create the handler... this is used to do work on the
    // UI thread from the handleEvent() method, which will
    // be called from another thread (usually).
    //
    mHandler =
        new Handler() {
          @Override
          public void handleMessage(Message msg) {
            Log.d("Handler", "a handle request occured on a non-UI thread... marshalling.");
            InContactEvent evt = (InContactEvent) msg.obj;
            if (evt.eventType == InContactEventType.ACTIVE_AGENTS_UPDATED) {
              setAdapter();
            }
          }
        };
  }